我正在使用yii mail swiftmailer扩展程序发送邮件。当我使用此邮件扩展名以及ccaptcha验证时,邮件不会发送到同一表格。当它单独使用而没有验证码验证时,它正在发送电子邮件。我需要使用此扩展程序发送电子邮件以及yii中的ccaptcha验证。
发送电子邮件:
$subjek="verifymail";
$from="sender@gmail.com";
$getEmail="to@gmail.com";
$message= new YiiMailMessage;
$message->subject=$subjek;
$message->from=$from;
$message->setBody($activationlink, 'text/html');
$message->addTo($getEmail);
Yii::app()->mail->send($message);
答案 0 :(得分:0)
我认为您在代码中缺少端口和主机信息,除非您没有显示整个代码,请参阅示例here
public function actionViewTest() {
// Render view and get content
// Notice the last argument being `true` on render()
$content = $this->render('viewTest', array(
'Test' => 'TestText 123',
), true);
// Plain text content
$plainTextContent = "This is my Plain Text Content for those with cheap emailclients ;-)\nThis is my second row of text";
// Get mailer
$SM = Yii::app()->swiftMailer;
// Get config
$mailHost = 'mail.example.com';
$mailPort = 25; // Optional
// New transport
$Transport = $SM->smtpTransport($mailHost, $mailPort);
// Mailer
$Mailer = $SM->mailer($Transport);
// New message
$Message = $SM
->newMessage('My subject')
->setFrom(array('from@example.com' => 'Example Name'))
->setTo(array('recipient@example.com' => 'Recipient Name'))
->addPart($content, 'text/html')
->setBody($plainTextContent);
// Send mail
$result = $Mailer->send($Message);
}
如果你的主机是gmail,请将端口设置为587或465
$mail->Port = 587; or $mail->Port = 465;
here是一个与您的问题几乎相似的问题