我想通过PHP发送邮件.. 我已经尝试通过php的邮件功能和phpmailer()函数了。 但我无法发送它 我已经尝试通过更改php.ini中的设置tooby设置端口号。至465,25 和获取帮助过网,但仍然是我的邮件不能正常工作多一些设置,我的代码身份验证错误尽管发送邮件在php
<html>
<head>
<title>PHPMailer - SMTP (Gmail) basic test</title>
</head>
<body>
<?php
date_default_timezone_set('asia/calcutta');
require_once('class.phpmailer.php');
$mail = new PHPMailer();
$body = "testing message";
$mail->IsSMTP(); // telling the class to use SMTP
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->SMTPSecure = "ssl"; // sets the prefix to the servier
$mail->Host = "smtp.gmail.com"; // sets GMAIL as the SMTP server
$mail->Port = 465; // set the SMTP port for the GMAIL server
$mail->Username = $_POST["u"]; // GMAIL username
$mail->Password = $_POST["p"]; // GMAIL password
$mail->SetFrom($_POST["u"], 'First Last');
$mail->Subject = "hello";
$mail->MsgHTML($body);
$address = $_POST["to"];
$mail->AddAddress($address, "info");
if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message sent!";
}
?>
</body>
</html>
我有一个其他页面以用户名,密码,发件人的电子邮件,并获得DEM DIS页。而我得到的错误是这样的:
Mailer Error: The following From address failed: s********@g***l.com : MAIL not accepted from server,530,5.5.1 Authentication Required. Learn more at 530 5.5.1 https://support.google.com/mail/answer/14257 sa9sm15580073pbc.18 - gsmtp
SMTP server error: 5.5.1 Authentication Required. Learn more at 530 5.5.1 https:/support.google.com/mail/answer/14257 sa9sm15580073pbc.18 - gsmtp
SMTP server error: 5.5.1 Authentication Required. Learn more at 530 5.5.1 https:/support.google.com/mail/answer/14257 sa9sm15580073pbc.18 - gsmtp
有时我也得到一个错误信息说:
called mail() without being connected mailer error in php
请帮助我的人.... 并提前致谢
你根据你的一个老示例代码,并可能正在使用旧版本的PHPMailer的。 [获取最新版本](https://github.com/PHPMailer/PHPMailer)。之后,[请阅读故障排除文档](https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting)。 – Synchro
尝试'$ mail-> SMTPSecure ='tls';',仔细检查用户名和密码。您可以检查PHPMailer [gmail文档](https://github.com/PHPMailer/PHPMailer/blob/master/examples/gmail.phps)。 –