Mailer错误:以下“发件人”地址失败:未连接时调用了Mail() [英] Mailer Error: The following From address failed: Called Mail() without being connected

查看:71
本文介绍了Mailer错误:以下“发件人”地址失败:未连接时调用了Mail()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 PHPMailer SMTP 发送电子邮件。我已经设置好所有内容。被连接


我知道要设置编码顺序,我也做到了,但是仍然存在相同的错误。请帮我解决这个问题。



我的代码:

I am using PHPMailer using SMTP to send Email. I have set everything.

But in the last I am getting error :
Mailer Error: The following From address failed: Email Address : Called Mail() without being connected

I came to know to set Order of coding, I also did it but still same error. Please help me to solve this issue.

My Code :

<?php

require 'PHPMailer.php';

error_reporting(E_ALL);
ini_set('display_errors', '1');

$name = $_POST["name"];
$email = $_POST["email"];
$subject = $_POST["subject"];
$message = $_POST["message"];

$mail = new PHPMailer();
$mail->IsSMTP();
$mail->Host = "smtp.live.com";
$mail->Port = 587;
$mail->SMTPAuth = true;
$mail->Username = "example@outlook.com";
$mail->Password = "password";
$mail->SMTPSecure = 'tls';

$mail->From = "info@neelcomputech.com";
$mail->FromName = $name;
$mail->AddAddress("info@neelcomputech.com");

$mail->IsHTML(true);

$mail->Subject = $subject;

$mail->Body = $mail_body = "<html> <body>";
$mail_body = "<b>Hello Admin,</b><br><br>You have got email from your website.<br><br>";
$mail_body .= '<table style="" cellpadding="3">';
$mail_body .= "
                <tr>
                <td width='50'> <strong> Name </strong> </td>
                <td width='5'> : </td>
                <td> $name </td>
                </tr>
                <tr>
                <td> <strong> Email </strong> </td>
                <td> : </td>
                <td> $email </td>
                </tr>
                <tr>
                <td> <strong> Message </strong> </td>
                <td> : </td>
                <td> $message </td>
                </tr>
                </table>
                </body> </html>"; 

if(!$mail->Send())
{
    echo 'Mailer Error: ' . $mail->ErrorInfo;
}
else
{
    echo 'success';
}

?>


推荐答案

<?php

    require 'PHPMailer.php';

    error_reporting(E_ALL);
    ini_set('display_errors', '1');

    $name = $_POST["name"];
    $email = $_POST["email"];
    $subject = $_POST["subject"];
    $message = $_POST["message"];

    $mail = new PHPMailer();
    $mail->IsSMTP();
    $mail->Host = "smtp.neelcomputech.com"; // Your SMTP PArameter
    $mail->Port = 587; // Your Outgoing Port
    $mail->SMTPAuth = true; // This Must Be True
    $mail->Username = "info@neelcomputech.com"; // Your Email Address
    $mail->Password = "YOUR PASSWORD"; // Your Password
    $mail->SMTPSecure = 'tls'; // Check Your Server's Connections for TLS or SSL

    $mail->From = "info@neelcomputech.com";
    $mail->FromName = $name;
    $mail->AddAddress("info@neelcomputech.com");

    $mail->IsHTML(true);

    $mail->Subject = $subject;

    $mail->Body = $mail_body = "<html> <body>";
    $mail_body = "<b>Hello Admin,</b><br><br>You have got email from your website.<br><br>";
    $mail_body .= '<table style="" cellpadding="3">';
    $mail_body .= "
                    <tr>
                    <td width='50'> <strong> Name </strong> </td>
                    <td width='5'> : </td>
                    <td> $name </td>
                    </tr>
                    <tr>
                    <td> <strong> Email </strong> </td>
                    <td> : </td>
                    <td> $email </td>
                    </tr>
                    <tr>
                    <td> <strong> Message </strong> </td>
                    <td> : </td>
                    <td> $message </td>
                    </tr>
                    </table>
                    </body> </html>"; 

    if(!$mail->Send())
    {
        echo 'Mailer Error: ' . $mail->ErrorInfo;
    }
    else
    {
        echo 'success';
    }

    ?>

您必须在smtp身份验证中使用自己的参数。
也可以在PHPMailer的网站上检查其他邮件服务器的smtp参数:
phpmailer.worxware.com/index.php?pg=tip_srvrs

You have to use your own parameters, in your smtp authentication. Also you can check other mail server's smtp parameters on PHPMailer's Website: phpmailer.worxware.com/index.php?pg=tip_srvrs

这篇关于Mailer错误:以下“发件人”地址失败:未连接时调用了Mail()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆