[SOLVED] Can't get to send HTML emails with this?
Posted: Tue Jun 05, 2007 8:10 am
I am trying to use SwiftMailer to send out an email with an attachment (from a contact form), and everything works great except it is only sending plain text emails. I would like it to send it as an HTML email. As you can see I tried setting the content-type to text/html, but no luck. Tried a few other things from the docs with no luck as well. Any guidance would be greatly appreciated. Thanks.
Code: Select all
//Create the sender from the details we've been given
$sender =& new Swift_Address($email, $name);
//Create the message to send
$message =& new Swift_Message("Message From: " . $name);
$message->setContentType("text/html");
$message->attach(new Swift_Message_Part($body));
# message sent time:
$clean['email_sent'] = date('Y:m:d h:i:s');
//If an attachment was uploaded, attach it
if ($upload_valid && isset($file_path) && isset($file_name) && isset($file_type))
{
$message->attach(new Swift_Message_Attachment(new Swift_File($file_path), $file_name, $file_type));
$clean['email_sent'] = date('Y:m:d h:i:s');
}
//Try sending the email
$sent = $swift->send($message, "info@example.com", $sender);
//Disconnect from SMTP, we're done
$swift->disconnect();