2013-01-07 212 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