I am new to Symfony Swift mailer. I have tried the following code bellow to configure the username and password
但是加载像Swift_SmtpTransport这样的类时出现问题。
$transport = Swift_SmtpTransport::newInstance('smtp.gmail.com', 465)
->setUsername('xxxxxxxx@gmail.com')
->setPassword('yyyyyy');
$mailer = Swift_Mailer::newInstance($transport);
$message = Swift_Message::newInstance();
$body="body-text";
$subject="subject-text";
$message->setSubject($subject)
->setFrom('xxxxxxxxx@gmail.com')
->setTo('zzzzzzzzz@gmail.com')
->setContentType('text/html')
->setBody($body);
$result = $mailer->send($message);
return $result;
提前致谢。
答案 0 :(得分:2)
$transport = \Swift_SmtpTransport::newInstance('smtp.gmail.com', 465)
->setUsername('xxxxxxxx@gmail.com')
->setPassword('yyyyyy');
$mailer = \Swift_Mailer::newInstance($transport);
$message = \Swift_Message::newInstance();