Swiftmailer一直在失败,我不明白为什么

时间:2014-02-26 03:31:22

标签: php swiftmailer

根据我的检查和die,它一直失败。有什么理由吗? SMTP设置正确...

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');
}

0 个答案:

没有答案