COO tiket.com. Advisor bouncity.com. Advisor golfnesia.com. Co-founded urbanesia.com. Initiator #StartupLokal
There’s a major bug in Swiftmailer, where sometimes your email returns 0 bytes attachment, or broken html email, or broken plaintext email in Yahoo? Well the cause of this is that Swiftmailer wrongly sends header and body. They forgot to separate the two.
--_=_swift_v4_13225521024ed48b26208bf_=_ Content-Type: application/pdf; name=#101086-8144-487-MOVIE.pdf Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename=#101086-8144-487-MOVIE.pdf JVBERi0xLjQKMyAwIG9iago8PC9UeXBlIC9QYWdlCi9QYXJlbnQgMSAwIFIKL1Jlc291cmNlcyAy IDAgUgovR3JvdXAgPDwvVHlwZSAvR3JvdXAgL1MgL1RyYW5zcGFyZW5jeSAvQ1MgL0RldmljZVJH
As you can see, between the header and the body sticks together. All you have to do:
/classes/Swift/Mime/SimpleMimeEntity.php
if ($this->_cache->hasKey($this->_cacheKey, ‘body’))
{
$body = “\r\n\r\n” .$this->_cache->getString($this->_cacheKey, ‘body’);
}
else
{
$body = “\r\n\r\n” . $this->_encoder->encodeString($this->getBody(), 0,
$this->getMaxLineLength()
);
$this->_cache->setString($this->_cacheKey, ‘body’, $body,
Swift_KeyCache::MODE_WRITE
);
}
At the cache, I added \r\n\r\n and at the else block, I added \r\n just to be safe. That’s all!