Adding MIME headers to emails sent using Swift Mailer

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
Sephirangel
Forum Commoner
Posts: 45
Joined: Tue Jul 15, 2008 1:37 pm

Adding MIME headers to emails sent using Swift Mailer

Post by Sephirangel »

Hello all,

I have the following mail script;

Code: Select all

<?php
        
        require_once('SwiftMailer/lib/swift_required.php');
        
        $transport = Swift_SmtpTransport::newInstance('SMTP.blueyonder.co.uk', 25)
        ->setUsername('xxxxx')
        ->setPassword('xxxxx')
        ;
        
        $mailer = Swift_Mailer::newInstance($transport);
        
        
        $message = Swift_Message::newInstance('New Knitterbabes Sales')
        ->setFrom(array('xxxxxx' => 'xxxxx'))
        ->setTo(array('xxxxxxxx' => 'xxxxxx'))
        ->setBody("<b>TEST</b>")
        ;
        
        $result = $mailer->send($message)
?>
My question is; how do i specify the email type? e.g. text/html so any HTML within the message gets rendered in the email (such as the <b> tags in the message)

thanks in advance!
Last edited by Benjamin on Mon May 18, 2009 5:20 pm, edited 1 time in total.
Reason: Changed code type from text to php.
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Re: Adding MIME headers to emails sent using Swift Mailer

Post by Benjamin »

Please reference the documentation on the swiftmailer website. Specifically there is documentation on sending multipart messages.
Sephirangel
Forum Commoner
Posts: 45
Joined: Tue Jul 15, 2008 1:37 pm

Re: Adding MIME headers to emails sent using Swift Mailer

Post by Sephirangel »

I have had a look through the SwiftMailer documentation but I am still unsure how to specify header type using the code I have used.
aarffy
Forum Newbie
Posts: 1
Joined: Mon Jun 08, 2009 10:33 am

Re: Adding MIME headers to emails sent using Swift Mailer

Post by aarffy »

It's not all that clear where it is. I found it, but it took a while.

http://swiftmailer.org/docs/message-body
Post Reply