2013-01-07 208 views
0
while (! file_exists('php')) 
     chdir('..'); 

include_once "php/Mail.php"; 

    $from = "<[email protected]>"; 
    $to = "<[email protected]>"; 
    $subject = "Hi!"; 
    $body = "Hi,\n\nHow are you?"; 

    $host = "ssl://smtp.gmail.com"; 
    $port = "465"; 
    $username = "[email protected]"; //<> give errors 
    $password = "xx"; 

    $headers = array ('From' => $from, 
     'To' => $to, 
     'Subject' => $subject); 
    $smtp = Mail::factory('smtp', 
     array ('host' => $host, 
     'port' => $port, 
     'auth' => true, 
     'username' => $username, 
     'password' => $password)); 

    $mail = $smtp->send($to, $headers, $body); 

    if (PEAR::isError($mail)) { 
     echo("<p>" . $mail->getMessage() . "</p>"); 
    } else { 
     echo("<p>Message successfully sent!</p>"); 
    } 

hello;我正在使用smtp郵件在s.o上給出的答案; (相信它的第一個結果,如果搜索)php smtp不發送郵件

但我仍然沒有收到郵件;任何人都可以幫助發現任何錯誤或提供ALT解決方案嗎?我已經使用內置的郵件程序,但未驗證請參閱 - >signing gmail with php imap

+1

我總是使用PHPMailer,它穩定,無bug,速度快,工作非常好。易於使用。簡單的例子[這裏](http://www.web-development-blog.com/archives/send-e-mail-messages-via-smtp-with-phpmailer-and-gmail/) – Peter

回答

0

在您的PHP ini文件中啓用了SSL嗎?

extension=php_openssl.dll