2015-06-11 54 views
0

它正在發送電子郵件。我需要發送電子郵件使用這個擴展以及yii中的ccaptcha驗證。Yii的快捷郵件沒有發送郵件

電子郵件:

$subjek="verifymail";  
$from="[email protected]"; 
$getEmail="[email protected]"; 
$message= new YiiMailMessage;   
$message->subject=$subjek;  
$message->from=$from; 
$message->setBody($activationlink, 'text/html'); 
$message->addTo($getEmail); 
Yii::app()->mail->send($message); 
+0

如果你在這裏添加你的代碼會更好,你在你的控制器發送郵件的動作中寫的是什麼,以及你的處理你的驗證碼的方式 –

+0

captcha我使用了ccaptcha驗證警予 –

回答

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('[email protected]' => 'Example Name')) 
    ->setTo(array('[email protected]' => '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是一個幾乎類似於你的問題的問題