base64 Encoding

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
bludginozzie
Forum Newbie
Posts: 2
Joined: Mon Jan 24, 2011 3:44 am

base64 Encoding

Post by bludginozzie »

Hi,

Firstly I luv this library, certainly it makes life a lot easier.

Question: How do you encode using base64? I notice the code has the capability but I cannot see any doc on how to do it. The doc in these forums is a bit out of date (i.e $message->headers->setEncoding("B") doesn't work).

The reason I am asking is because the 78 char line split is causing issues in some readers. If the split occurs in the middle of a html attribute some email readers don't like it. I tried this $message->setMaxLineLength(1000); but that didn't work either. It still split at 78 chars.

Thanks in advance.
bludginozzie
Forum Newbie
Posts: 2
Joined: Mon Jan 24, 2011 3:44 am

Re: base64 Encoding

Post by bludginozzie »

Sorry to bother you but I ended up figuring this out. Here is waht I did just in case someone else has this problem;

Code: Select all

$message = Swift_Message::newInstance();
$message->setEncoder(Swift_Encoding::getBase64Encoding());
/*
 * Set up your text/plain body here
 */
$message->setBody($myTextPlainBody);
/*
 * Set up your text/html body here
 */
$htmlPart = Swift_MimePart::newInstance($myHtmlBody, 'text/html', null);
$htmlPart->setEncoder(Swift_Encoding::getBase64Encoding());
$message->attach($htmlPart);
If this is not right then please let me know.

Thanks
Post Reply