Page 1 of 1

text/html wrapped in text/plain

Posted: Mon Mar 19, 2007 8:28 am
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

Posted: Mon Mar 19, 2007 10:45 am
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");