[SOLVED] How do I change embedded content headers?

Swift Mailer is a fantastic library for sending email with php. Discuss this library or ask any questions about it here.

Moderators: Chris Corbyn, General Moderators

Post Reply
User avatar
Kadanis
Forum Contributor
Posts: 180
Joined: Tue Jun 20, 2006 8:55 am
Location: Dorset, UK
Contact:

[SOLVED] How do I change embedded content headers?

Post 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
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post 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).
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post 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 ;)
User avatar
Kadanis
Forum Contributor
Posts: 180
Joined: Tue Jun 20, 2006 8:55 am
Location: Dorset, UK
Contact:

Post by Kadanis »

Brilliant news. I'll keep an eye out for the new release.

Thanks for the help.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post 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);
User avatar
Kadanis
Forum Contributor
Posts: 180
Joined: Tue Jun 20, 2006 8:55 am
Location: Dorset, UK
Contact:

Post by Kadanis »

Cool. Thanks mate. Downloaded and will have a play this afternoon
User avatar
Kadanis
Forum Contributor
Posts: 180
Joined: Tue Jun 20, 2006 8:55 am
Location: Dorset, UK
Contact:

Post by Kadanis »

Worked perfectly. Thank you again.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

No problem, glad I could help :)
Post Reply