Page 1 of 1

[SOLVED] How do I change embedded content headers?

Posted: Thu May 24, 2007 6:00 am
by Kadanis
Hi

I don't know if this is possible in Swift, or maybe I'm barking up the wrong tree.

Basically, we are trying to automate a newsletter process using Swift Mailer. At the moment, it is manually sent via an app called Gammadyne and uses embedded images. When sent from Gammadyne the images appear inline and display perfectly. Using Swift, they don't. I have sent examples of an identical email to myself and the only difference is outlined below. Is it possible to change this?

Gammadyne :

Code: Select all

------=_NextPart_000_0012_28D29E01.9F9E580C
Content-Type: image/jpeg; name="ibm_video.jpg"
Content-ID: <ibm_video.jpg>
Content-Transfer-Encoding: base64
Swift:

Code: Select all

--_=_swift-58224444146556c48876ea3.76318779_=_
Content-Type: image/jpeg; name=ibm_video.jpg
Content-Disposition: inline; filename=ibm_video.jpg
Content-ID: <swift-118000340046556c486ae66.0>
Content-Transfer-Encoding: base64
Obviously, I understand the boundary id's will be different each time, but Swift is adding in the line Content-Disposition: inline; filename=ibm_video.jpg.

Any advise would be great (even if its telling me why not to do this ^^, need to present something back to boss)

Thanks in advance for any help

Posted: Thu May 24, 2007 6:15 am
by Chris Corbyn
You can go ahead and remove content-disposition. It's there because some mail clients will not download the files with relevant filenames without it. Not all mail clients take the filename from the same header. If you're not arsed about people saving the images then:

Code: Select all

//Setting to null is effectively unsetting a header (it won't get used)
$file->headers->setAttribute("Content-Disposition", "filename", null);
$file->headers->set("Content-Disposition", null);
(I'm changing the logic a little so you don't have to clear all attributes before clearing a header -- this is an oversight on my part).

Posted: Thu May 24, 2007 6:20 am
by Chris Corbyn
Apologies, I just tested that code and it doesn't work. I'm releasing a new version in an hour or so anyway so gimme a few mins and I'll make it work ;)

Posted: Thu May 24, 2007 6:40 am
by Kadanis
Brilliant news. I'll keep an eye out for the new release.

Thanks for the help.

Posted: Thu May 24, 2007 7:06 am
by Chris Corbyn
Kadanis wrote:Brilliant news. I'll keep an eye out for the new release.

Thanks for the help.
3.2.4 available now. It just has a few small tweaks over 3.2.3 which may reduce the likelihood of being seen as spam.

All you need to do is:

Code: Select all

$embedded_file->headers->set("Content-Disposition", null);

Posted: Thu May 24, 2007 7:26 am
by Kadanis
Cool. Thanks mate. Downloaded and will have a play this afternoon

Posted: Thu May 24, 2007 9:13 am
by Kadanis
Worked perfectly. Thank you again.

Posted: Thu May 24, 2007 9:53 am
by Chris Corbyn
No problem, glad I could help :)