我无法使用PHPMailer通过ipage主机发送电子邮件。
我有以下错误:
**邮件错误:以下发件人地址失败:maria@mydomain.com:未连接称为Mail()
<?php
//Import PHPMailer classes into the global namespace
require 'PHPMailer/class.phpmailer.php';
function smtpmailer($to, $from, $from_name, $subject, $body, $is_gmail = false) {
global $error;
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->SMTPAuth = true;
$mail->SMTPSecure = 'ssl';
$mail->Host = 'mail.mydomain.com';
$mail->Port = 993;
$mail->Username = "maria@cgi.mydomain.com";
$mail->Password = "mypassword";
$mail->SetFrom($from, $from_name);
$mail->Subject = $subject;
$mail->Body = $body;
$mail->AddAddress($to);
if(!$mail->Send()) {
$error = 'Mail error: '.$mail->ErrorInfo;
return false;
} else {
$error = 'Message sent!';
return true;
}
}
$msg = 'Hello World';
$subj = 'test mail message';
$to = 'mail@gmail.com';
$from = 'maria@mydomain.com';
$name = 'maa';
if (!smtpmailer($to, $from, $name, $subj, $msg, false)) {
if (!empty($error)) echo $error;
} else {
echo 'Yep, the message is send (after doing some hard work)';
}
?>
错误日志移到此处:
SMTP -> FROM SERVER:220 ESMTP Wed, 20 Sep 2017 09:57:47 -0400: UCE strictly prohibited SMTP -> FROM SERVER: 250-bosauthsmtp15.yourhostingaccount.com Hello localhost [156.204.159.206] 250-SIZE 34603008 250-8BITMIME 250-PIPELINING 250-AUTH PLAIN LOGIN 250-STARTTLS 250 HELP SMTP -> FROM SERVER:220 TLS go ahead SMTP -> FROM SERVER: 250-bosauthsmtp15.yourhostingaccount.com Hello localhost [156.204.159.206] 250-SIZE 34603008 250-8BITMIME 250-PIPELINING 250-AUTH PLAIN LOGIN 250 HELP SMTP -> ERROR: Username not accepted from server: 535 Incorrect authentication data SMTP -> FROM SERVER:250 Reset OK SMTP -> FROM SERVER:550 bosauthsmtp15: Host 156.204.159.206: No unauthenticated relaying permitted SMTP -> ERROR: MAIL not accepted from server: 550 bosauthsmtp15: Host 156.204.159.206: No unauthenticated relaying permitted The following From address failed: maria@cgi.mydomain.com : MAIL not accepted from server,550,bosauthsmtp15: Host 156.204.159.206: No unauthenticated relaying permitted
SMTP server error: bosauthsmtp15: Host 156.204.159.206: No unauthenticated these is what I get
relaying permitted Mail error: The following From address failed: maria@cgi.mydomain.com : MAIL not accepted from server,550,bosauthsmtp15: Host 156.204.159.206: No unauthenticated relaying permitted
SMTP server error: bosauthsmtp15: Host 156.204.159.206: No unauthenticated relaying permitted
SMTP server error: bosauthsmtp15: Host 156.204.159.206: No unauthenticated relaying permitted