繁体   English   中英

在GMAIL中收到电子邮件正文时为空白-Swiftmailer

[英]Email body is blank when receiving it in GMAIL - Swiftmailer

自从我开始使用Swiftmailer以来,我一直遇到这个问题。 我知道我是新手,所以可能做错了什么。 任何帮助,将不胜感激。

问题是:我仅在GMAIL中收到空白的正文,但在OUTLOOK / YAHOO中收到了所有预期的内容。

我不确定是什么问题。 在此先感谢您的回答。

在这里,我调用该函数以发送具有所有属性的电子邮件

    $subject = "CROCT Admin - Evaluate performance of participant for project  - '".$result2['project_name']."'";
    $from = array('test@test.com' => 'Tasty');
    $to = $result4[$i]['email'];
    $body = 'Hello, You have got an invitiation to participate your work in project '.$result2['project_name'].' Accept the invitation and start participating in it.' .anchor('https://example.org/'.$project_id_url.'/'.$result4[$i]['user_id'], 'Accept Invitation');
    $addpart = 'Best,Team CROCT';
    $this->**send_email($subject, $from, $to, $body, $addpart)**;

这是send_mail的功能

    function send_email($subject, $from, $to, $body, $addpart)
        {
            require_once APPPATH.'libraries/swift_mailer/swift_required.php';
            //Create the Transport
            $transport = Swift_MailTransport::newInstance();
            /*
            You could alternatively use a different transport such as Sendmail or Mail:
            //Sendmail
            $transport = Swift_SendmailTransport::newInstance('/usr/sbin/sendmail -bs');
            //Mail
            $transport = Swift_MailTransport::newInstance();
            */
            //Create the message
            $message = Swift_Message::newInstance();
            //Give the message a subject
            $message->setSubject($subject)
                    ->setFrom($from)
                    ->setTo($to)
                    ->setBody($body, 'text/plain')
                    ->addPart($addpart, 'text/html')
            ;
            //Create the Mailer using your created Transport
            $mailer = Swift_Mailer::newInstance($transport);
            //Send the message
            $result = $mailer->send($message);
            if ($result) {
                $this->session->set_flashdata('error', 'Invitation sent.');
            } else {
                $this->session->set_flashdata('error', 'Error occured.');
            }
        }

这就是我在Gmail中收到的方式 结果我收到电子邮件-仅用于GMAIL

这就是我在Outlook中收到的方式 这就是我在《展望》中收到的

这是我零钱后收到的 在此处输入图片说明

至于评论,所有主要的电子邮件提供商都应接受。

测试:

  • Gmail的
  • 外表
  • 雅虎
  • 安装Kerio

MailFunction:

function send_email($subject, $from, $to, $body, $addpart)
        {
            require_once APPPATH.'libraries/swift_mailer/swift_required.php';
            //Create the Transport
            $transport = Swift_MailTransport::newInstance();
            /*
            You could alternatively use a different transport such as Sendmail or Mail:
            //Sendmail
            $transport = Swift_SendmailTransport::newInstance('/usr/sbin/sendmail -bs');
            //Mail
            $transport = Swift_MailTransport::newInstance();
            */
            //Create the message
            $message = Swift_Message::newInstance();
            //Give the message a subject
            $message->setSubject($subject)
                    ->setFrom($from)
                    ->setTo($to)
                    ->setBody($body, 'text/html')
            ;
            //Create the Mailer using your created Transport
            $mailer = Swift_Mailer::newInstance($transport);
            //Send the message
            $result = $mailer->send($message);
            if ($result) {
                $this->session->set_flashdata('error', 'Invitation sent.');
            } else {
                $this->session->set_flashdata('error', 'Error occured.');
            }
        }

属性:

$subject = "CROCT Admin - Evaluate performance of participant for project  - '".$result2['project_name']."'";
$from = array('test@test.com' => 'Tasty');
$to = $result4[$i]['email'];
$body = 'Hello, You have got an invitiation to participate your work in project '.$result2['project_name'].' Accept the invitation and start participating in it.' .anchor('https://example.org/'.$project_id_url.'/'.$result4[$i]['user_id'], 'Accept Invitation').'<br>Best,Team CROCT';
$this->**send_email($subject, $from, $to, $body)**;

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM