如何使用PHPMailer通过godaddy发送电子邮件?

问题描述 投票:2回答:3

我正在尝试几天通过godaddy帐户从我的网站发送电子邮件。我不知道服务器端是否有任何特殊配置(godaddy)我不知道我的PHP代码是否也有任何错误。我真的需要弄清楚如何发送电子邮件。谢谢,里卡多。

enter code here
    try {

        //Create a new PHPMailer instance
        $mail = new PHPMailer();

        $mail->isSMTP();
        //Enable SMTP debugging
        // 0 = off (for production use)
        // 1 = client messages
        // 2 = client and server messages
        $mail->SMTPDebug   = 2;
        $mail->DKIM_domain = '**********';

        $mail->Debugoutput = 'html';

        $mail->Host        = "a2plcpnl0321.prod.iad2.secureserver.net";

        $mail->Port        = 465;

        $mail->SMTPAuth    = true;
        //Username to use for SMTP authentication
        $mail->Username    = "***************.com";
        //Password to use for SMTP authentication
        $mail->Password    = "**99KKll";
        $mail->SMTPSecure  = 'ssl';
        //Set who the message is to be sent from
        $mail->setFrom('****************.com', '*******');
        //Set an alternative reply-to address
        //$mail->addReplyTo('[email protected]', 'First Last');
        //Set who the message is to be sent to
        $mail->addAddress('**************.com', '*****');

        //Set the subject line
        $mail->Subject = 'PHPMailer SMTP test';
        $mail->Body = "<i>This is the Link to change your password:</i>";
        //Replace the plain text body with one created manually
        $mail->AltBody = 'This is a plain-text message body';


        //send the message, check for errors
        if (!$mail->send()) {
            echo "Mailer Error: " . $mail->ErrorInfo;
        } else {
            echo "Message sent!";
        } 
        print_r($mail); 
php
3个回答
0
投票

你抓错了吗?

try {
    // your mail code
    // $mail->send();
} catch (phpmailerException $e) {
    echo $e->errorMessage(); //Pretty error messages from PHPMailer
} catch (Exception $e) {
    echo $e->getMessage(); //Boring error messages from anything else!
}

0
投票
SERVER -> CLIENT: 220-a2plcpnl0321.prod.iad2.secureserver.net ESMTP Exim 4.85 #2 Fri, 26 Feb 2016 16:15:57 -0700 220-We do not authorize the use of this system to transport unsolicited, 220 and/or bulk e-mail.
CLIENT -> SERVER: EHLO warneracademy.com
SERVER -> CLIENT: 250-a2plcpnl0321.prod.iad2.secureserver.net Hello a2plcpnl0321.prod.iad2.secureserver.net [*************]250-SIZE 52428800250-8BITMIME250-PIPELINING250-AUTH PLAIN LOGIN250 HELP
CLIENT -> SERVER: AUTH LOGIN
SERVER -> CLIENT: 334 VXNlcm5hbWU6
CLIENT -> SERVER: cmVxdWVzdEB3YXJuZXJhY2FkZW15LmNvbQ==
SERVER -> CLIENT: 334 UGFzc3dvcmQ6
CLIENT -> SERVER: Kio5OUtLbGw=
SERVER -> CLIENT: 235 Authentication succeeded
CLIENT -> SERVER: MAIL FROM:<**************>
SERVER -> CLIENT: 250 OK
CLIENT -> SERVER: RCPT TO:<*************>
SERVER -> CLIENT: 250 Accepted
CLIENT -> SERVER: DATA
SERVER -> CLIENT: 354 Enter message, ending with "." on a line by itself
CLIENT -> SERVER: Date: Fri, 26 Feb 2016 23:15:52 +0000
CLIENT -> SERVER: To: Ricardo Scarpim <**************>
CLIENT -> SERVER: From: WarnerAcademy <**************>
CLIENT -> SERVER: Subject: PHPMailer SMTP test
CLIENT -> SERVER: Message-ID: <[email protected]>
CLIENT -> SERVER: X-Mailer: PHPMailer 5.2.13 (https://github.com/PHPMailer/PHPMailer)
CLIENT -> SERVER: MIME-Version: 1.0
CLIENT -> SERVER: Content-Type: multipart/alternative;
CLIENT -> SERVER: boundary="b1_5fa4a06963e0e5c2e64a8e88e553bc10"
CLIENT -> SERVER: Content-Transfer-Encoding: 8bit
CLIENT -> SERVER: 
CLIENT -> SERVER: This is a multi-part message in MIME format.
CLIENT -> SERVER: 
CLIENT -> SERVER: --b1_5fa4a06963e0e5c2e64a8e88e553bc10
CLIENT -> SERVER: Content-Type: text/plain; charset=us-ascii
CLIENT -> SERVER: 
CLIENT -> SERVER: This is a plain-text message body
CLIENT -> SERVER: 
CLIENT -> SERVER: 
CLIENT -> SERVER: --b1_5fa4a06963e0e5c2e64a8e88e553bc10
CLIENT -> SERVER: Content-Type: text/html; charset=us-ascii
CLIENT -> SERVER: 
CLIENT -> SERVER: <i>This is the Link to change your password:</i>
CLIENT -> SERVER: 
CLIENT -> SERVER: 
CLIENT -> SERVER: 
CLIENT -> SERVER: --b1_5fa4a06963e0e5c2e64a8e88e553bc10--
CLIENT -> SERVER: 
CLIENT -> SERVER: .
SERVER -> CLIENT: 250 OK id=1aZRc5-001CJG-Tk
CLIENT -> SERVER: QUIT
SERVER -> CLIENT: 221 a2plcpnl0321.prod.iad2.secureserver.net closing connection
Message sent!

0
投票

经过多次尝试......这对Godaddy来说很有用[20/12/2017]

require 'PHPMailerAutoload.php';
$mail = new PHPMailer();
//$mail->isSMTP();                                      
//isSMTP seems to be the problem..  because it sends locally
$mail->SMTPDebug   = 0;
//$mail->DKIM_domain = '127.0.0.1';
$mail->Host       = "localhost";
$mail->Port       = "25";
$mail->SMTPSecure = "none";
$mail->SMTPAuth   = false;
$mail->Username   = "";
$mail->Password   = "";
© www.soinside.com 2019 - 2024. All rights reserved.