php-reports
php-reports copied to clipboard
mail issues - bad header - misinterpreted content
The latest seems to be buggy and prone mix mime boundaries while sending report mail.
One symptom lead to: X-Amavis-Alert: BAD HEADER SECTION, MIME error: error: unexpected end of preamble
After hours of test, this seems to be related to this issue within SwiftMailer, applying this patch fixes the boundary mix: https://github.com/swiftmailer/swiftmailer/pull/565
Considering my report are full utf-8 (japanese content), I also added 8Bit encoding to ensure proper delivery/display lib/PhpReport/PhpReports.php line 482 on my version
// Create the message
$message = Swift_Message::newInstance()
->setEncoder(Swift_Encoding::get8BitEncoding())
->setSubject($subject)
->setFrom($from)
->setTo($email)
//html body
->setBody($email_html, 'text/html', 'utf-8')
//text body
->addPart($email_text, 'text/plain', 'utf-8')
;
$attachment = Swift_Attachment::newInstance()
->setFilename('report.csv')
->setContentType('text/csv')
->setBody($csv, 'text/csv', 'utf-8')
;