我可以从我的本地服务器发送电子邮件。但是,当我试图从Web服务器发送电子邮件则显示以下信息:没有发送 消息 梅勒错误:语言字符串未能加载:connect_host如何使用phpmailer从网络服务器发送电子邮件
这里是我的代码:
<?php
require("class.phpmailer.php");
$name=$_POST['name'];
$company=$_POST['company'];
$email=$_POST['email'];
$phone=$_POST['phone'];
$subject=$_POST['subject'];
$question=$_POST['question'];
$mailer = new PHPMailer();
$mailer->IsSMTP();
$mailer->Host = 'ssl://smtp.gmail.com';
$mailer->Port = 465; //can be 587
$mailer->SMTPAuth = TRUE;
$mailer->Username = '[email protected]'; // Change this to your gmail address
$mailer->Password = '*********'; // Change this to your gmail password
$mailer->From = '[email protected]'; // Change this to your gmail address
$mailer->FromName = 'Client'; // This will reflect as from name in the email to be sent
$mailer->Body = "Name :".$name."\n\nCompany :".$company."\n\nEmail :".$email."\n\nPhone :".$phone."\n\n\n".$question."";
$mailer->Subject = $subject;
$mailer->AddAddress('[email protected]'); // This is where you want your email to be sent
/*$mailer->AddAttachment('attach_file/'.$_FILES["file"]["name"]);*/
if(!$mailer->Send())
{
echo "Message was not sent<br/ >";
echo "Mailer Error: " . $mailer->ErrorInfo;
}
else
{
header ('Location:index.html');
}
?>
一些供应商阻止邮件功能,以防止垃圾邮件发送来自他们的系统。你有哪些提供者? –
我从本地托管提供商公司租用服务器。 eicra soft ltd – user1493448
我建议你试试SwiftMailer。 –