0
    while (! file_exists('php') )
        chdir('..');

include_once "php/Mail.php";

    $from = "<me@gmail.com>";
    $to = "<you@gmail.com>";
    $subject = "Hi!";
    $body = "Hi,\n\nHow are you?";

    $host = "ssl://smtp.gmail.com";
    $port = "465";
    $username = "foo@gmail.com";  //<> 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>");
     }

你好; 我正在使用在 smtp 邮件中给出的答案;(相信它的第一个结果,如果搜索)

但是我仍然没有收到邮件;任何人都可以帮助发现任何错误或提供替代解决方案吗?我使用了内置的邮件程序,但它没有经过身份验证,请参阅 ->使用 php imap 签署 gmail

4

1 回答 1

0

您的 PHP ini 文件中是否启用了 SSL?

extension=php_openssl.dll
于 2013-01-07T01:53:26.807 回答