简体   繁体   English

PHP的SMTP不发送电子邮件

[英]php smtp not sending email

    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>");
     }

hello; 你好; i am using the answer that was given on so for smtp mailing; 我正在使用smtp邮件中给出的答案; (believe its the first result if search) (如果进行搜索,请相信其第一个结果)

yet i still do not receive the mail; 但是我仍然没有收到邮件; can anyone help to spot any error or provide alt solutions? 谁能帮助您发现任何错误或提供替代解决方案? I have used the built in mailer but it is not being authenticated see -> signing gmail with php imap 我已经使用了内置的邮件程序,但是未通过身份验证,请参阅-> 用php imap签名gmail

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

extension=php_openssl.dll

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM