text/html wrapped in text/plain

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
cmc
Forum Newbie
Posts: 1
Joined: Mon Mar 19, 2007 8:14 am

text/html wrapped in text/plain

Post by cmc »

I am trying to send a multipart message with the PHP5 version of Swiftmailer 3. I had this working previously in SwiftMailer2/PHP4. Now both parts of the message are wrapped in a text\plain boundaries. The html part of the message is visible in the message source, but not in the rendered message.

This is the relevant section of code.

Code: Select all

$swiftHtml = new Swift_Message_Part($messageHtml);
    $swiftPlain = new Swift_Message_Part(strip_tags(p2nl($messageHtml)));

    $connection = new Swift_Connection_SMTP("localhost");
    $swift = new Swift($connection);
	
    $swiftMessage = new Swift_Message($subject);
	
    //Add as many parts as you like
    $swiftMessage->attach($swiftPlain);
    $swiftMessage->attach($swiftHtml, "text/html");
	
    //Addresses
    $swiftBcc = new Swift_Address($strEmail);
    $swiftTo = new Swift_Address($strEmail, $strName);
    $swiftFrom = new Swift_Address($strEmail, $strName);
    
    $recipients = new Swift_RecipientList();
    $recipients->addTo($swiftTo);
    $recipients->addBcc($swiftBcc);
	
    $swift->send($swiftMessage, $recipients, $swiftFrom);
TIA. Sorry if this is answered elsewhere. I couldn't find it.

-cathy
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

Code: Select all

$swiftHtml = new Swift_Message_Part($messageHtml); 

//no no no ... it's this:

$swiftHtml = new Swift_Message_Part($messageHtml, "text/html");
Post Reply