相关疑难解决方法(0)

遇到PHPMailer问题

我正在尝试使用PHPMailer发送gmail电子邮件.我跟着这篇文章

为此,我设置了如下所示的函数:

function sendEmail($email, $name) {
    $mail = new PHPMailer();
    $mail->IsSMTP(); // send via SMTP
    //IsSMTP(); // send via SMTP I commented it cos it gives an error
    $mail->SMTPAuth = true; // turn on SMTP authentication
    $mail->Username = 'email@gmail.com'; // Changed my email
    $mail->Password = "password";// Changed my password
    $mail->From = 'email@gmail.com';
    $mail->FromName = 'FROM NAME';


    $mail->AddAddress($email);

    $mail->IsHTML(true); // send as HTML
    $mail->Subject = "Subject";
    $mail->Body = "Body";

    if (!$mail->Send()) {
        return false;
    } else {
        return true;
    } …
Run Code Online (Sandbox Code Playgroud)

php gmail

17
推荐指数
1
解决办法
4万
查看次数

升级到php 7后出现fsockopen错误

我在数字海洋nginx和php 7上运行codeigniter3.03.当我尝试发送电子邮件时,我收到此错误:

码:

严重性:警告消息:fsockopen():无法连接到ssl://smtp.googlemail.com:465(连接超时)文件名:libraries/Email.php行号:1986

我的电子邮件设置是

$config['useragent'] = 'CodeIgniter';
$config['protocol'] = 'smtp';
//$config['mailpath'] = '/usr/sbin/sendmail';
$config['smtp_host'] = 'ssl://smtp.googlemail.com';
$config['smtp_user'] = 'xxxxxx@gmail.com';
$config['smtp_pass'] = 'xxxxxxxxxxxx';
$config['smtp_port'] = 465; 
$config['smtp_timeout'] = 5;
$config['wordwrap'] = TRUE;
$config['wrapchars'] = 76;
$config['mailtype'] = 'html';
$config['charset'] = 'utf-8';
$config['validate'] = FALSE;
$config['priority'] = 3;
$config['crlf'] = "\r\n";
$config['newline'] = "\r\n";
$config['bcc_batch_mode'] = FALSE;
$config['bcc_batch_size'] = 200;
Run Code Online (Sandbox Code Playgroud)

这个版本在php 5.x下的同一配置中运行完美.

在php.ini我有

 extension=php_openssl.dll
Run Code Online (Sandbox Code Playgroud)

启用.

我无法得到任何暗示,为什么这不应该在php7中工作.任何人都可以给我一个提示要检查的内容或者这个错误的原因是什么.

php nginx codeigniter-3

8
推荐指数
1
解决办法
996
查看次数

Phpmailer使用smtp与Gmail无法正常工作 - 连接超时

我查看了以下链接:

phpmailer发送gmail smtp超时

通过PHP邮件程序使用Gmail SMTP服务器发送电子邮件

http://uly.me/phpmailer-and-gmail-smtp/

...并试图为自己实现这些的组合......但大多数时候它发送此消息......

无法发送消息.

邮件程序错误:SMTP连接()失败.

然而有一次,当我在"tls"和"ssl"之间进行实验时,它发送了这个...

SMTP错误:无法连接到服务器:连接超时(110)SMTP连接()失败.无法发送消息.

邮件程序错误:SMTP连接()失败.

我的代码附上了...我不知道错过了什么?我问网络托管服务是否阻止并给他们一个我的代码模板 - 他们说服务器允许连接到Gmail的SMTP.

    require_once("class.phpmailer.php");
    $mail = new PHPMailer();
    $mail -> IsSMTP();
    $mail -> SMTPDebug = 2;
    $mail -> SMTPAuth = 'true';
    $mail -> SMTPSecure = 'tls';
    $mail -> SMTPKeepAlive = true;
    $mail -> Host = 'smtp.gmail.com';
    $mail -> Port = 587;
    $mail -> IsHTML(true); 

    $mail -> Username = "myemail@gmail.com";
    $mail -> Password = "mypassword";
    $mail -> SingleTo = true; 

    $to = xxx;                           
    $from = xxx;
    $fromname = xxx; …
Run Code Online (Sandbox Code Playgroud)

php email ssl gmail phpmailer

4
推荐指数
1
解决办法
3万
查看次数

标签 统计

php ×3

gmail ×2

codeigniter-3 ×1

email ×1

nginx ×1

phpmailer ×1

ssl ×1