BKF
BKF

Reputation: 1366

send mails via swift mailer

I try to send a mail via swiftmailer and my code is :

$message->setFrom($from);
$message->setBody($template, 'text/html');
$message->setTo($from);
$message->addPart($text, 'text/plain');
//$message->attach(Swift_Attachment::fromPath('D:/file.txt'));
// send message
if ($recipients = $swift->send($message, $failures)) { 

but the problem is I recieve an empty message ! $template is a variable which contains html code !

Upvotes: 0

Views: 1560

Answers (1)

JPG Dev
JPG Dev

Reputation: 51

Forget about $failures parameter. Just use a try catch !

try 
{
    //... all of your code
    $swift->send($message);
}
catch(Exception $exception)
{
    //A big object containing the error message
    print_r($exception);
}

Upvotes: 2

Related Questions