我可以從我的本地服務器發送電子郵件。但是,當我試圖從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。 –