My application stores a large number of XML files. Background work periodically sends some of these XML files to a specific mailbox. The mailer code is simple:
class MailSender < ActionMailer::Base
default :from => AppConfig.mail_from
smtp_settings :address => AppConfig.smtp_host,
:username => AppConfig.smtp_user,
:password => AppConfig.smtp_pass
def send_xml(record)
f = record.filename.gsub("\\", "/")
f_short = arq.gsub(/.*\//, "")
f_phys = "#{AppConfig.xml_root}#{arq}"
headers["Return-Receipt-To"] = AppConfig.return_receipt
attachments[f_short] = File.read(f_phys) if File.exists?(f_phys)
mail :subject => "...",
:to => AppConfig.mail_to
end
end
However, for some reason, these XMLs are corrupted during transmission: the first line break is added in column 987, and the following are added in column 990. After each break, space is inserted. I think the picture speaks for itself:
col 1 col 990
|.................................................|
<?xml version="1.0" ... </IE><IM>321505493301<
/IM><CNAE>4744001< ... 00</pCOFINS><vCOFINS>0.00
</vCOFINS></COFINS ... /prod><imposto><ICMS><ICM
S40><orig>0</orig> ... <infAdic><infCpl>Permite
I tried calling File.readmyself on rails console, it works great, no line breaks are added. Therefore, I assume that the error should lie on ActionMailer. Any tips?
:. XML . , XML - , , .