【问题标题】:SMTP With gmail error. I'm not receiving the emailSMTP 出现 gmail 错误。我没有收到电子邮件
【发布时间】:2016-09-30 03:47:09
【问题描述】:

我有什么遗漏吗?我搜索了高低,我不确定我的代码有什么问题。还是我使用的是公共而不是邮件?

    <?php
require_once('phpmailer.php');
class Mail extends PhpMailer
{
    // Set default variables for all new objects
    public $mail     = IsSMTP;   
    public $From     = 'register@lolvoid.net23.net';
    public $FromName = SITETITLE;
    public $Host     = 'smtp.gmail.com';
    public $port     = 587;
    public $Mailer   = 'smtp';
    public $SMTPAuth = true;
    public $Username = 'email@gmail.com';
    public $Password = 'password';
    public $SMTPSecure = 'tls';
    public $WordWrap = 75;

    public function subject($subject)
    {
        $this->Subject = $subject;
    }

    public function body($body)
    {
        $this->Body = $body;
    }

    public function send()
    {
        $this->AltBody = strip_tags(stripslashes($this->Body))."\n\n";
        $this->AltBody = str_replace("&nbsp;", "\n\n", $this->AltBody);
        return parent::send();
    }
}

这是我当前的代码,问题尚未解决。有什么新想法吗?

【问题讨论】:

标签: php


【解决方案1】:

将端口更改为 SMTP 的安全端口:465

【讨论】:

    【解决方案2】:

    端口应该是 587 而不是 4587。

    这是默认的 Gmail SMTP 设置;

    • Gmail SMTP 服务器地址:smtp.gmail.com
    • Gmail SMTP 用户名:您的 完整的 Gmail 地址(例如 yourusername@gmail.com)
    • Gmail SMTP 密码:您的 Gmail 密码
    • Gmail SMTP 端口 (TLS):587
    • Gmail SMTP 端口 (SSL):465
    • 需要 Gmail SMTP TLS/SSL:是

    你能换行吗

    public $mail = 'IsSMTP()'
    

    以下内容:

    public $mail = IsSMTP();
    

    【讨论】:

    • 您建议将 gmail 凭据发送到 smtp.mandrillapp.com ?
    • @zerkms 我搞错主机了。
    • 已编辑,未收到正面结果
    • 您是否尝试更改我在编辑的解决方案中提到的行? @Jayy
    【解决方案3】:

    很可能是一个端口。

     public $port     = '4587';
    

    如果您尝试在端口 465 上配置 SMTP 服务器(使用 SSL/TLS) 和端口 587(使用 STARTTLS),但仍然无法发送 邮件,请尝试将您的 SMTP 配置为使用端口 25(使用 SSL/TLS)。

    Apple Mail 用户:有时,Mail 可能会误解您的 SMTP 服务器 设置。如果您目前有 'smtp.gmail.com:username@gmail.com' 在 您设置的“发送邮件服务器:”字段,请尝试 将字段更改为“smtp.gmail.com”并保存您的设置。

    https://support.google.com/mail/answer/78775?hl=en

    你混合了 465 和 587 端口。

    如果还是不行,可以试试调试连接。例如,请参阅PHPMailer only sends email when SMTPDebug = true

    另外,来自文档:

    /**
     * SMTP class debug output mode.
     * Debug output level.
     * Options:
     * * `0` No output
     * * `1` Commands
     * * `2` Data and commands
     * * `3` As 2 plus connection status
     * * `4` Low-level data output
     * @var integer
     * @see SMTP::$do_debug
     */
    public $SMTPDebug = 0;
    

    用它来找出可能是什么问题。它会告诉你它停在哪里。

    【讨论】:

    • 已修复,但还是没有
    猜你喜欢
    • 2019-05-06
    • 1970-01-01
    • 1970-01-01
    • 2018-05-13
    • 2014-01-04
    • 1970-01-01
    • 2022-01-21
    • 2016-07-12
    • 1970-01-01
    相关资源
    最近更新 更多