CakePHP 电子邮件无法在 Mosso 云网站上发送

发布于 2024-07-16 19:14:18 字数 1227 浏览 11 评论 0原文

我已将可用的 Cakephp Web 应用程序上传到 Mosso Cloud Sites 托管。 该应用程序工作正常,只是不再发送电子邮件。 该网站与我以前的主机完全相同,发送电子邮件可以正常工作。 该应用程序使用内置的 Cakephp 电子邮件组件。 我搜索了 Mosso 的知识库,并按照 此处。 我的脚本如下:

    $this->Email->reset();
    $this->Email->sendAs = 'html'; // both = html + plain text
    $this->Email->to = '"'.$data['Customer']['first_name'].' '.$data['Customer']['last_name'].'" <' . $data['Customer']['email']. '>';
    $this->Email->bcc = $this->_generateRecipients($data['Booking']['sales_associate_id']);
    $this->Email->from = '<noreply@'.env('HTTP_HOST').'>';
    $this->Email->replyTo = '<noreply@'.env('HTTP_HOST').'>';
    $this->Email->return = '<noreply@'.env('HTTP_HOST').'>';
    $this->Email->subject = 'Rental Receipt';

    // Select appropraite email template
    switch ($this->Session->read('site_id')) {
        case '100':
            $this->Email->template = 'vac_receipt1';
            break;
        case '200':
            $this->Email->template = 'vac_receipt2';
            break;
    }

    $this->Email->send();

I have uploaded a working Cakephp web application to Mosso Cloud Sites hosting. The application is working fine except that emails are no longer being delivered. The site is an exact copy from my previous host, where sending email was working correctly. The app uses the built in Cakephp email component. I have searched Mosso's knowledgebase and followed the directions for php email (htaccess method) here. My script is as follows:

    $this->Email->reset();
    $this->Email->sendAs = 'html'; // both = html + plain text
    $this->Email->to = '"'.$data['Customer']['first_name'].' '.$data['Customer']['last_name'].'" <' . $data['Customer']['email']. '>';
    $this->Email->bcc = $this->_generateRecipients($data['Booking']['sales_associate_id']);
    $this->Email->from = '<noreply@'.env('HTTP_HOST').'>';
    $this->Email->replyTo = '<noreply@'.env('HTTP_HOST').'>';
    $this->Email->return = '<noreply@'.env('HTTP_HOST').'>';
    $this->Email->subject = 'Rental Receipt';

    // Select appropraite email template
    switch ($this->Session->read('site_id')) {
        case '100':
            $this->Email->template = 'vac_receipt1';
            break;
        case '200':
            $this->Email->template = 'vac_receipt2';
            break;
    }

    $this->Email->send();

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

烟若柳尘 2024-07-23 19:14:18

我会发表评论,但还没有声誉..

无论如何,你检查过 send() 返回值吗? 您的日志文件中是否有任何错误? 如果没有错误并且返回值正常,您可能应该联系主机的支持人员。

I would post a comment but don't have the reputations yet..

Anyway, did you check the send() return value? Do you get any errors in your log files? If there are no errors and the return value is fine, you should probably contact the support of your host.

通知家属抬走 2024-07-23 19:14:18

在与 Mosso 员工详细讨论该问题后,他们的一位 Linux 管理员介入并在检查代码后指出,Mosso 云站点电子邮件系统不支持对代码生成的电子邮件进行密件抄送或抄送。 因此,由于我的代码使用密件抄送向我们的员工以及客户发送副本,所以我的电子邮件没有被发送,也没有抛出任何 PHP 错误。

因此,如果您使用 Mosso Cloud 站点,则无法通过代码密件抄送或抄送发送电子邮件。 吸取了教训,但应该更容易在他们的知识库中找到一些东西。

After discussing the issue with the Mosso staff at length one of their linux admins stepped in and after reviewing the code noted that the Mosso Cloud Sites email system does NOT support Bcc or Cc on code generated emails. So since my code was using Bcc to send a copy to our staff as well as to the customer my emails were not being sent and no PHP errors were being thrown.

So if you use Mosso Cloud sites you cannot send emails with Bcc or Cc from code. Lesson learned, but something that should be easier to find in their knowledge base.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文