As indicated on my previous post, I am using swiftmailer to send HTML emails to my list of about 800 emails.
I am already able to send them out no problem, but I'm having issues with the customization of part of the message. I took a look at the Decorator plugin as suggested by d11wtq but I still need a little help.
This is my message as it stands right now. I'm creating the message body outside of the loop as it will be the same to everyone (thanks d11wtq for the hint) except the link at the bottom.
Code: Select all
require_once "../tools/Swift-3.1.2-php5/lib/Swift.php";
require_once "../tools/Swift-3.1.2-php5/lib/Swift/Connection/SMTP.php";
//Start Swift
$smtp =& new Swift_Connection_SMTP("mail.myserver.com", 587);
$smtp->setUsername("mylogin");
$smtp->setpassword("mypw");
$swift =& new Swift($smtp);
$result = mysql_query("SELECT recipient_email FROM common_recipients WHERE list_id=$list_id");
// build email message
$html_body = "<strong> message here </strong>";
$text_body = "message here";
//Create the message
$message =& new Swift_Message(urldecode($message_subject));
//Add some "parts"
$message->attach(new Swift_Message_Part($html_body, "text/html"));
$message->attach(new Swift_Message_Part($text_body, "text/plain"));
while ($row = mysql_fetch_array ($result)){
//Now check if Swift actually sends it
if ($swift->send($message, urldecode($row['recipient_email']), urldecode($message_from_email))) echo "Sent";
else echo "Failed";
}Code: Select all
// create Unsubscribe link at the end of every message sent
$unsubscribe = '<div align="center"><font size="1" face="Verdana, Arial, Helvetica, sans-serif"> Click <a href="http://www.mysite.com/unsubscribe.php?email='.$row['recipient_email'].'">here </a>to unsubscribe from our mailing list </font></div>';I tried using the $message->attach(new Swift_Message_Part($body, "text/html")); to attach another part on my email but it doesn't work
Any ideas?
thanks.
[/b]