我有这个脚本用gmail SMTP发送邮件
require 'mailPhp/PHPMailerAutoload.php';
$email= $_POST['Email'];
echo $email;
$clientFolder= $GLOBALS['directory'];
$mail = new PHPMailer;
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'smtp.gmail.com'; // Specify main and backup server
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = 'user@gmail.com'; // SMTP username
$mail->Password = 'password'; // SMTP password
$mail->SMTPSecure = 'ssl'; // Enable encryption, 'ssl' also accepted
$mail->Port = 465; //Set the SMTP port number - 587 for authenticated TLS
$mail->setFrom('contact@azura-space.com', 'Fuyor Romania'); //Set who the message is to be sent from
$mail->addReplyTo('contact@bocher.us', 'Comenzi Fuyor Romania'); //Set an alternative reply-to address
$mail->addAddress("$email"); // Add a recipient
$mail->WordWrap = 50; // Set word wrap to 50 characters
// $mail->addAttachment('/usr/labnol/file.doc'); // Add attachments
$mail->addAttachment("$clientFolder/file.pdf", 'DeliveryOrder.pdf');
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = 'Comanda Fuyor';
$mail->Body = 'Va multumim ca ati cumparat de la noi. V-am trimis o copie
dupa comanda dvs in acest mail.';
if(!$mail->send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
exit;
}
echo 'Message has been sent';
如果它从http域运行,这工作正常,但当我把它放在https域时,它给了我这个错误: 邮件程序错误:SMTP连接()失败。 https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
另外,我试图将安全方法和端口从tls 587更改为ssl 465但是不起作用。脚本在两个域上都是相同的... 问题在哪里?