繁体   English   中英

无法使用 Godaddy 电子邮件凭据使用 PHP 发送邮件

[英]Unable to send mail using PHP using Godaddy email credentials

代码:

<?php
    try {
        require_once "Mail.php";
        require_once "Mail/mime.php";
        $from = "support@domain.com";
        $to = "user@gmail.com";
        $subject = "Testing email please ignore";
        $message = "Just testing";
        $host = "godaddyhost";
        $port = "465";
        $username = "support@domain.com";
        $password = "password";
        $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, $message); 
        if (PEAR::isError($mail)) { 
              echo("<p>" . $mail->getMessage() . "</p>");
        } else {
                echo("<p>Message successfully sent!</p>");
        }

    } catch(Exception $e) {
        echo $e;
    }
    ?>

我在执行上述script在浏览器中遇到问题

This page isn’t working
localhost is currently unable to handle this request.
HTTP ERROR 500

如果我从$mail = $smtp->send($to, $headers, $message);注释我的代码$mail = $smtp->send($to, $headers, $message); 只是简单地echo "something"; 然后我可以在浏览器上看到一些东西

日志

[Wed Dec 27 17:07:36.033665 2017] [:error] [pid 28115] [client ::1:41546] PHP Warning:  include_once(Net/SMTP.php): failed to open stream: No such file or directory in /usr/share/php/Mail/smtp.php on line 365
[Wed Dec 27 17:07:36.033715 2017] [:error] [pid 28115] [client ::1:41546] PHP Warning:  include_once(): Failed opening 'Net/SMTP.php' for inclusion (include_path='.:/usr/share/php:/usr/share/pear') in /usr/share/php/Mail/smtp.php on line 365
[Wed Dec 27 17:07:36.033741 2017] [:error] [pid 28115] [client ::1:41546] PHP Fatal error:  Class 'Net_SMTP' not found in /usr/share/php/Mail/smtp.php on line 366

请安装“Net/”类。

在 Linux 机器上使用此命令, sudo pear install Net_SMTP

pear install Net_SMTP为 Windows 机器pear install Net_SMTP 或者

下载以下内容,并将它们放入/Net

http://pear.php.net/package/Net_SMTP/download

http://pear.php.net/package/Net_Socket/download

暂无
暂无

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

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