根据我的检查和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');
}