Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/286.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
无法使用gmail帐户使用php mailer发送电子邮件_Php_Phpmailer - Fatal编程技术网

无法使用gmail帐户使用php mailer发送电子邮件

无法使用gmail帐户使用php mailer发送电子邮件,php,phpmailer,Php,Phpmailer,在这里,我无法使用我的gmail帐户使用PHPMailer发送电子邮件。 示例代码: <?php require_once('phpmailerclass/class.phpmailer.php'); $mail = new PHPMailer(); $mail->IsSMTP(); $mail->Mailer = 'smtp'; $mail->SMTPAuth = true; $mail->Host = 'smtp.gmail.com'; $mail->

在这里,我无法使用我的gmail帐户使用PHPMailer发送电子邮件。 示例代码:

<?php
require_once('phpmailerclass/class.phpmailer.php');

$mail = new PHPMailer();
$mail->IsSMTP();
$mail->Mailer = 'smtp';
$mail->SMTPAuth = true;
$mail->Host = 'smtp.gmail.com'; 
$mail->Port = 568;
$mail->SMTPSecure = 'ssl';

$mail->Username = "myEmail@gmail.com";
$mail->Password = "myPassword";

$mail->IsHTML(true); // if you are going to send HTML formatted emails

$mail->From = "ramalingam.p@pickzy.com";
$mail->FromName = "Ramalingam";

$mail->addAddress("yoursramalingam@gmail.com","Luu Van Minh");

$mail->Subject = "Testing PHPMailer with localhost";
$mail->Body = "Hi,<br /><br />This system is working perfectly.";

if(!$mail->Send())
{
     echo "Message was not sent <br />PHPMailer Error: " . $mail->ErrorInfo;
}   
else
{
    echo "Message has been sent";
}      
?>
我还在gmail设置中启用“不太安全”。 但它将超越错误。指定我的有效gmail发件人地址。
请纠正我的错误。

如果使用ssl,请将端口587更改为465

$mail->Port = 465;
$mail->SMTPSecure = 'ssl';

我认为GMail不允许您发送带有
发件人地址的电子邮件,该地址与您用于“登录”SMTP服务器的实际帐户不同。您的端口不应该是587吗?您使用的是旧版本的PHPMailer,并且您的代码基于一个过时的示例。我建议您。邮件没有在localhost中发送,当我运行localhost时,它将抛出相同的错误。但实时服务器工作正常。有什么想法吗?检查openssl是否启用,如果未启用,则在php.ini文件中启用openssl,找到此代码;extension=php_openssl.dll并删除第一个分号。它已启用。但是邮件没有发送。从PHP info->
OpenSSL支持:enabled
添加一个参数$mail->SMTPDebug=true;输入代码并检查确切的错误。在此发布该错误。SMTP->错误:无法连接到服务器:(0)以下发件人地址失败:ramalingam。p@pickzy.com
$mail->Port = 465;
$mail->SMTPSecure = 'ssl';