0

It keeps failing as per my below check and die. Any reason why? The SMTP settings are correct...

require_once '../lib/swift_required.php';

// Create the Transport the call setUsername() and setPassword()
$transport = Swift_SmtpTransport::newInstance('smtp.server.com', 25)
  ->setUsername('email@server.com')
  ->setPassword('password')
  ;

// Create the Mailer using your created Transport
$mailer = Swift_Mailer::newInstance($transport);


// Creating a test message
$message = Swift_Message::newInstance('Wonderful Subject')
  ->setFrom(array('john@doe.com' => 'John Doe'))
  ->setTo(array('receiver@domain.org', 'other@domain.org' => 'A name'))
  ->setBody('Here is the message itself')
  ;

// Send the message
$numSent = $mailer->send($message);

if ($mailer->send($message))
{
  die('Mail sent');
} else {
  die('Error: Mail failed');
}
DT.DTDG
  • 765
  • 1
  • 13
  • 31
  • You should check what error is being thrown, and go from there. Have a look at http://stackoverflow.com/questions/2386544/error-handling-with-phpmailer – Roberto Feb 26 '14 at 03:39
  • @Rob: Thanks Rob. Is there one for swiftmailer rather than phpmailer? – DT.DTDG Feb 26 '14 at 03:42
  • 1
    Definitely, have you tried searching "swiftmailer get error"? Also, the documentation might be of help: http://swiftmailer.org/docs/sending.html#getting-failures-by-reference – Roberto Feb 26 '14 at 03:45

0 Answers0