cakephp到gmail被阻止

发布于 2025-02-10 02:33:17 字数 2584 浏览 3 评论 0原文

我很难通过非Gmail帐户通过CakePHP 2 将电子邮件发送到Gmail帐户。 (编辑)

gmail的错误代码: 550-5.7.26此消息没有身份验证信息,或者

服务器中没有SPF记录,我可以使用Thunderbird(例如Thunderbird)将电子邮件发送到Gmail。

这是我的代码。

/app/config/email.php

class EmailConfig {

public $email = array(
        'transport' => 'Smtp',
        'host' => 'mail.example.com',
        'port' => 587,
        'timeout' => 30,
        'username' => '[email protected]',
        'password' => 'password',
        'log' => false,
        'returnPath' => '[email protected]',
);

}

进行了一些谷歌搜索后,我也尝试过。

class EmailConfig {

public $email = array(
        'transport' => 'Smtp',
        'host' => 'mail.example.com',
        'port' => 587,
        'timeout' => 30,
        'username' => '[email protected]',
        'password' => 'password',
        'log' => false,
        'SMTPSecure' => 'starttls',
        'tls' => true,
        'context'=>array('ssl' => array(
        'verify_peer' => false,
        'verify_peer_name' => false,
        'allow_self_signed' => true

控制器

            $email = new CakeEmail('ap');

            $email->charset = 'ISO-2022-JP';

            $result = $email

            ->config(array('log' => 'emails'))

            ->to(array($this->request->data['Order']['mail']))

            ->bcc(array(Configure::read ('Mail.Bcc')))
            ->from(array(Configure::read ('Mail.FromMail')=> 'MyBusinessName'))
            ->subject($this->request->data['Order']['order_subject'])
            ->send($this->request->data['Order']['message']);

            if (!$result) {
                $this->Session->setFlash(__('MailSend Failed Retry Again '));
                return;
            } else {

                $this->OrderMailHistory->commit();
                $this->OrderStateHistory->commit();
                $this->Order->commit();

                $this->redirect(array('action' => 'detail/', $this->request->data['Order']['id']));

            }

        }

可以建议我们如何将电子邮件发送到Gmail? 非常感谢!

I'm having trouble sending emails to Gmail accounts through CakePHP 2 from a non-Gmail account. (EDIT)

Error code from Gmail:
550-5.7.26 This message does not have authentication information or fails to

SPF records are present in the server and I am able to send emails to Gmail using email software like Thunderbird.

Here is my code.

/app/Config/email.php

class EmailConfig {

public $email = array(
        'transport' => 'Smtp',
        'host' => 'mail.example.com',
        'port' => 587,
        'timeout' => 30,
        'username' => '[email protected]',
        'password' => 'password',
        'log' => false,
        'returnPath' => '[email protected]',
);

}

After some Googling, I tried this way as well.

class EmailConfig {

public $email = array(
        'transport' => 'Smtp',
        'host' => 'mail.example.com',
        'port' => 587,
        'timeout' => 30,
        'username' => '[email protected]',
        'password' => 'password',
        'log' => false,
        'SMTPSecure' => 'starttls',
        'tls' => true,
        'context'=>array('ssl' => array(
        'verify_peer' => false,
        'verify_peer_name' => false,
        'allow_self_signed' => true

Controller

            $email = new CakeEmail('ap');

            $email->charset = 'ISO-2022-JP';

            $result = $email

            ->config(array('log' => 'emails'))

            ->to(array($this->request->data['Order']['mail']))

            ->bcc(array(Configure::read ('Mail.Bcc')))
            ->from(array(Configure::read ('Mail.FromMail')=> 'MyBusinessName'))
            ->subject($this->request->data['Order']['order_subject'])
            ->send($this->request->data['Order']['message']);

            if (!$result) {
                $this->Session->setFlash(__('MailSend Failed Retry Again '));
                return;
            } else {

                $this->OrderMailHistory->commit();
                $this->OrderStateHistory->commit();
                $this->Order->commit();

                $this->redirect(array('action' => 'detail/', $this->request->data['Order']['id']));

            }

        }

Can someone please advise how we can get emails to be sent to Gmail?
Thanks so much!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文