繁体   English   中英

php mailer无法将电子邮件发送给除我以外的任何人

[英]php mailer cannot send email to anyone except myself

我正在使用php mailer类向我的客户发送电子邮件。 但失败并显示错误:

Language string failed to load: recipients_failed example@gmail.com

如果我将$ email_to和$ email_from的值更改为相同的电子邮件地址,则电子邮件发送成功

这是我发送电子邮件的代码

$email_to = "example@gmail.com";
$email_subject = "bla bla";
$email_from = 'info@domain.com.vn';
$email_message = "hello there";

$mail = new PHPMailer();
$mail->CharSet="UTF-8";
$mail->IsSMTP(); // telling the class to use SMTP
$mail->Host = "mail.domain.com.vn"; // SMTP server
$mail->From = $email_from;
$mail->AddAddress($email_to);
$mail->AddReplyTo($email_from);     
$mail->Subject = $email_subject;
$mail->WordWrap = 100; 
$mail->Body = $htmlBody;
$mail->isHTML(true);
$mail->AltBody = $email_message;
if(!$mail->Send()){
   echo $mail->ErrorInfo; 
}

因此,除非我将$ email_to更改为info@domain.com.vn,否则它将始终报告错误。

谢谢,

注意:请将SMTP服务器设置更改为您自己的服务器。

$your_email = "info@example.com";
$your_smtp = "mail.example.com";
$your_smtp_user = "info@example.com";
$your_smtp_pass = "example_password";
$your_website = "http://example.com";

//get contact form details
$name = $_POST['name'];
$email = $_POST['email'];
$url = $_POST['url'];
$comments = $_POST['comments'];

$response="Name: $name\nContents:\n$comments\n";

$mail = new PHPmailer();
$mail = $mail->SetLanguage("en", "phpmailer/language");
$mail->From = $your_email;
$mail->FromName = $your_website;
$mail->Host = $your_smtp;
$mail->Mailer   = "smtp";
$mail->Password = $your_smtp_pass;
$mail->Username = $your_smtp_user;
$mail->Subject = "$your_website feedback";
$mail->SMTPAuth  =  "true";
$mail->Body = $response;
$mail->AddAddress($your_email,"$your_website admin");
$mail->AddReplyTo($email,$name);

echo "<p>Thanks for your feedback, <em>$name</em>! We will contact you soon!</p>";
if (!$mail->Send()) {
echo "<p>There was an error in sending mail, please try again at a later time</p>";
}

$mail->ClearAddresses();
$mail->ClearAttachments();

我认为您需要像这样设置语言和语言文件的路径:

$mail->SetLanguage ("de", "./phpmailer/");

如果这不能解决。 确保语言文件确实存在于该文件夹中(如果可能,请使用相对路径)并且在Linux下:这些文件应与php脚本具有相同的所有者,并且正确(读取文件权限)。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM