Page 1 of 1

A little more help with embedded images

Posted: Fri May 25, 2007 4:04 am
by Kadanis
Hi Mate,

First off thanks for the help yesterday. The Content-Disposition thing worked perfectly and the new system is looking lovely.

On a slight tangent, we have a second system that is getting on a bit, and uses PHPMailer for its sending operations. Long term I am going to (once I've persuaded the boss) change it to Swift, but in the short term they want to get it working with PHPMailer.

The main thing I've noticed is that when the 2 mailers create the base64 for the image file Swift has an extra line at the top. When translated into text it is something like JFIF.... or aGIF32...., but still unique to each image.

This is the top few lines from a base64 encoded image in PHPMailer

Code: Select all

AQEBAgICAgICAgICAgICAgICAgICAgICAgICAgICAgL/2wBDAQEBAQEBAQICAgICAgICAgICAgIC
AgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgL/wAARCADwAUADAREA
AhEBAxEB/8QAHwAAAQQCAwEBAAAAAAAAAAAAAAUGBwgECQEDCgIL/8QAWhAAAQIEBAMDBwgFCQUF
BAsAAQIDBAUGEQAHEiEIEzEiQVEJFBcjMmFxFUJXgZGYodYWJLHB8BgZMzhSeLjR4SVicoLxJzRD
kpcKRFjUKDU2N0VTVmODosT/xAAcAQABBQEBAQAAAAAAAAAAAAAAAQIDBAUGBwj/xABIEQABAwID
and this is the same image in Swift

Code: Select all

/9j/4AAQSkZJRgABAQEASABIAAD/2wBDAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQECAQEB  <--- this is the additional line
AQEBAgICAgICAgICAgICAgICAgICAgICAgICAgICAgL/2wBDAQEBAQEBAQICAgICAgICAgICAgIC
AgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgL/wAARCADwAUADAREA
AhEBAxEB/8QAHwAAAQQCAwEBAAAAAAAAAAAAAAUGBwgECQEDCgIL/8QAWhAAAQIEBAMDBwgFCQUF
BAsAAQIDBAUGEQAHEiEIEzEiQVEJFBcjMmFxFUJXgZGYodYWJLHB8BgZMzhSeLjR4SVicoLxJzRD
kpcKRFjUKDU2N0VTVmODosT/xAAcAQABBQEBAQAAAAAAAAAAAAAAAQIDBAUGBwj/xABIEQABAwID
I assume its some kind of identifier for image type, but what ever it is it means that the encoded images in swift are perfect but the ones in phpmail are corrupted.

Would you be able to tell me / point me in the right direction of how you have included this extra information, so I can attempt a hotfix to PHPMailer for the short term solution, while we re-build the old mailer in Swift

If this is too much trouble I understand completely, as its really nothing to do with Swift itself.

Posted: Fri May 25, 2007 5:13 am
by Chris Corbyn
:? I don't do anything. I take the raw file contents and base64_encode() them. Well, that's not strictly true... I read 8190 bytes, base64 encode, read another 8190 bytes, etc etc but the end result should be the same. The only reason I do it like that is that it uses less memory to base64 encode data in smaller portions so Swift uses less memory than PHPMailer for these tasks. It shouldn't add anything that's not there but it's nice here that Swift Mailer is performing tasks PHPMailer cannot perform so well :)

I'll have a quick look at the PHPMailer code to see if I can identify it but last time I looked at the code I got lost in a sea of spaghetti so I can't make any promises ;)