2012-02-28 82 views
2

我試過了,但我得到了「錯誤:無法連接到服務器:無法找到套接字傳輸」ssl「 - 您忘記在配置PHP時啓用它嗎?」您可以使用PHPmailer從localhost發送電子郵件嗎?

$mail = new \PHPMailer(true); 

$mail->IsSMTP(); 
$mail->Host  = "smtp.gmail.com"; 
$mail->Port  = 465; 
$mail->SMTPDebug = 2; 
$mail->SMTPAuth = true; 
$mail->SMTPSecure = 'ssl'; 
$mail->Username = "[email protected]"; 
$mail->Password = "wr^#@[email protected])(f"; 

$mail->AddAddress('[email protected]', 'John Doe'); 
$mail->SetFrom('[email protected]', 'First Last'); 
$mail->Subject = 'PHPMailer Test Subject via mail(), advanced'; 
$mail->MsgHTML('Add some HTML here'); 
$mail->Send(); 
+1

可能的重複http://stackoverflow.com/questions/6168882/phpmailer-to-use-gmail-as-smtp-server-could-not-connect-to-smtp-host-mailer-err – Electronick 2012-02-28 18:54:37

+0

對不起我啓用該擴展,它的作品謝謝! – Alex 2012-02-28 18:56:31

回答

相關問題