2013-06-01 82 views
1

我有与XAMPP和WAMP相同的问题。我不确定是什么原因导致此问题,因为日志文件中完全没有。Laravel/XAMPP/Sendmail不发送邮件

我三重检查了我的配置,一切都如它应该我甚至关闭了我的防火墙,但什么也没有发生。

Laravel 4投的这个(超时)异常:Symfony\Component\Debug\Exception\FatalErrorException

\vendor\swiftmailer\swiftmailer\lib\classes\Swift\Transport\StreamBuffer.php165 

public function readLine($sequence) 
{ 
    if (isset($this->_out) && !feof($this->_out)) { 
     $line = fgets($this->_out); 
     if (strlen($line)==0) { 

此功能Laravel 4使用读取模板文件。但是访问该文件没有问题,因为它是正确命名的,并且位于正确的文件夹中。这就是发送邮件的方法是这样的一个:

Mail::send('emails.activate', array('url' => $url), function($message) { 
     $message->to(trim(Input::get('email')))->subject('Account activation.'); 
    }); 

而Laravel的从config文件夹mail.php:

<?php 

return array(
    'driver' => 'smtp', // Changed this to mail() and sendmail same error 
    'host' => 'smtp.gmail.com', 
    'port' => 465, 
    'from' => array('address' => '[email protected]', 'name' => 'Support Team'), 
    'encryption' => 'tls', 
    'username' => '****@gmail.com', 
    'password' => '*****', 
    'sendmail' => 'C:\xampp\sendmail\sendmail.exe -t', 
); 

在我的php.ini文件我有:

[mail function] 
; XAMPP: Comment out this if you want to work with an SMTP Server like Mercury 
SMTP = smtp.gmail.com 
smtp_port = 465 

; For Win32 only. 
; http://php.net/sendmail-from 
sendmail_from = ****@gmail.com 


; XAMPP: Comment out this if you want to work with fakemail for forwarding to your mailbox (sendmail.exe in the sendmail folder) 
sendmail_path = "\"C:\xampp\sendmail\sendmail.exe\" -t" 

而且在我的sendmail.ini中我有:

smtp_server=smtp.gmail.com 
smtp_port=465 
smtp_ssl=auto 
error_logfile=error.log 
auth_username=****@gmail.com 
auth_password=**** 
pop3_server= 
pop3_username= 
pop3_password= 
force_sender= 
force_recipient= 
hostname= 

我ha一切设置正确,我关掉防火墙,检查我的路由器无法跟踪它。

回答

2

我张贴的答案here可能解决这个一段。

总之,使用端口465时,需要将默认加密设置从tls更改为ssl。

'host' => 'smtp.gmail.com', 
'port' => 465, 
'encryption' => 'ssl', 
0

你可能搞明白了现在,但我认为这个问题是您

Mail::send('emails.activate', array('url' => $url), function($message) { 
    $message->to(trim(Input::get('email')))->subject('Account activation.'); 
}); 

尝试将其更改为:

$to = trim(Input::get('email')); 
    $subject = 'Account activation.'; //for illustration purposes 
    Mail::send('emails.activate', array('url' => $url), function($message) use ($to, $subject){ 
    $message->to($to)->subject($subject); 
}); 
0

如果gmail阻止了你,并且不允许你使用你的凭据登录尝试这个。

登录您的Gmail帐户,不是去: https://accounts.google.com/b/0/DisplayUnlockCaptcha

,并单击继续和比你有几分钟的时间与你的代码发送邮件。 之后,谷歌将允许从新来源登录到该帐户。