gpt4 book ai didi

php - 使用 Hotmail smtp 在 PHP 中发送邮件

转载 作者:行者123 更新时间:2023-12-02 04:34:09 34 4
gpt4 key购买 nike

我正在尝试使用 Hotmail Smtp 以 PHP 发送邮件。但我收到如下错误:

2014-03-13 06:59:01 CLIENT -> SERVER: EHLO site.com 
2014-03-13 06:59:01 CLIENT -> SERVER: AUTH LOGIN
2014-03-13 06:59:01 SMTP ERROR: AUTH command failed: 504 5.3.3 AUTH mechanism LOGIN not available
2014-03-13 06:59:01 CLIENT -> SERVER: QUIT SMTP connect() failed. Mailer Error: SMTP connect() failed.

请有人告诉我我做错了什么吗?

我的代码:

error_reporting(E_STRICT);
require_once('class.phpmailer.php');
include('class.smtp.php');
$mail = new PHPMailer(); //Initialize a new PHPMailer object;
//$body = preg_replace("[\]",'',$body); //Replace unwanted characters of the content
$mail->CharSet ="ISO-8859-1";//Set the character set you need to specify
$mail->IsSMTP(); // Use SMTP service
$mail->SMTPDebug = 1; // Enable debugging for SMTP
// 1 = errors and messages
// 2 = messages only
$mail->From = '<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="badbd8d9fad2d5ced7dbd3d694d9d5d7" rel="noreferrer noopener nofollow">[email protected]</a>';
$mail->FromName = 'Name';
$mail->SMTPAuth = true;
$mail->SMTPSecure = "SSL";
$mail->Host = 'smtp.live.com';
$mail->Port = '465';


$mail->Username = '<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="19787b7a5971766d74787075377a7674" rel="noreferrer noopener nofollow">[email protected]</a>'; //Username of your email account
$mail->Password = '***'; //Password of your email account

$mail->SetFrom('a<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="274544674f48534a464e4b0944484a" rel="noreferrer noopener nofollow">[email protected]</a>', 'Name');
$mail->AddReplyTo('<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="6a0b08092a02051e070b030644090507" rel="noreferrer noopener nofollow">[email protected]</a>','Name');
$mail->Subject = $subject;
$mail->AltBody = 'To view the message, please use an HTML compatible email viewer!'; // optional, comment out and test
$mail->MsgHTML($body);
$address = $to;
$mail->AddAddress($address, '');
//$mail->AddAttachment("images/phpmailer.gif"); // attachment
//$mail->AddAttachment("images/phpmailer_mini.gif"); // attachment

//var_dump($body);
if(!$mail->Send()) {
//echo $body;

echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
echo "Message sent successfully!";
}

需要帮助。谢谢。

我该如何解决这个问题?任何人的帮助将不胜感激。

最佳答案

以下对我有用:

    $mail = new PHPMailer();    $mail->SMTPSecure = 'tls';    $mail->Username = "[email protected]";    $mail->Password = "mypassword";    $mail->AddAddress("[email protected]");    $mail->FromName = "My Name";    $mail->Subject = "My Subject";    $mail->Body = "My Body";    $mail->Host = "smtp.live.com";    $mail->Port = 587;    $mail->IsSMTP();    $mail->SMTPAuth = true;    $mail->From = $mail->Username;    $mail->Send();

关于php - 使用 Hotmail smtp 在 PHP 中发送邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22371724/

34 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com