Using Variable in Message Part

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
jackfranklin
Forum Newbie
Posts: 2
Joined: Thu Apr 17, 2008 3:57 pm

Using Variable in Message Part

Post by jackfranklin »

Hi,

$message->attach(new Swift_Message_Part($themessage));

Is that possible? I've tried doing it, it gives no errors, but doesn't display the message.

Any help greatly appreciated!
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Re: Using Variable in Message Part

Post by Chris Corbyn »

Where's the rest of your code? That is certainly possible so something else must be getting done incorrectly ;)
jackfranklin
Forum Newbie
Posts: 2
Joined: Thu Apr 17, 2008 3:57 pm

Re: Using Variable in Message Part

Post by jackfranklin »

$swift = new Swift(new Swift_Connection_SMTP("my smtp"));
$message = new Swift_Message($subject);
$message->attach(new Swift_Message_Part($themessage));

$message->attach(new Swift_Message_Part("Part of my message", "text/html"));

$recipients =& new Swift_RecipientList();
$recipients->addTo($to);
//Use addCc()
$recipients->addCc($cc);
$recipients->addBcc($bcc);
//Now check if Swift actually sends it
if ($swift->send($message, $recipients, "email@mysite.com"))

My only thought is that it is not finding the variable $themessage, but I'm positive it does. If you can't see anything wrong with the above I'll check again.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Re: Using Variable in Message Part

Post by Chris Corbyn »

Where does $themessage come from? :) Not from a form by any chance? Have you tried:

Code: Select all

var_dump($themessage);
?
Post Reply