【问题标题】:CodeIgniter weird emails being sentCodeIgniter 正在发送奇怪的电子邮件
【发布时间】:2013-08-19 11:17:59
【问题描述】:

我有一个函数,我可以传递参数以轻松发送电子邮件。

就是这样:

function __construct() {
        $this -> CI = get_instance();
        $this -> CI -> load -> library('email');
    }

    public function send_one_email($single_email, $single_subject, $single_body, $single_attach) {
        $this -> CI -> email -> clear();
        $this -> CI -> email -> to($single_email);
        $this -> CI -> email -> from('**************');
        $this -> CI -> email -> subject($single_subject);
        $this -> CI -> email -> message($single_body);

        if ($single_attach) {
            $this -> CI -> email -> attachment($single_attach);
        }

        if ($this -> CI -> email -> send()) {
            return TRUE;
        }
    }

我收到的电子邮件是(我不应该收到的):

?= =?utf-8?Q?2013?= 回复:“SUNYOrangeScholarInterface@gmail.com” X 发件人: SUNYOrangeScholarInterface@gmail.com X-Mailer:CodeIgniter X-Priority: 3(正常)消息 ID: Mime 版本:1.0 内容类型:多部分/替代;边界="B_ALT_520eb8d943598"

这是一个 MIME 格式的多部分消息。您的电子邮件应用程序 可能不支持这种格式。

--B_ALT_520eb8d943598 内容类型:文本/纯文本; charset=utf-8 内容传输编码:8bit

您好 Rixhers Ajazi,这是一封自动发送的电子邮件,用于通知您您的 帐号已成功创建,请等待您的帐号 待验证意味着您无权使用 学者界面。一旦您的帐户被激活,您将获得一个 用户角色将通过电子邮件通知您。请注意,由于 您已经创建了您的帐户 您有责任保存您的 凭证安全。其中包括您的电子邮件帐户、您对 您的安全问题,以及您的密码本身。我(Rixhers Ajazi) 只是想警告您,如果您不保留安全答案 安全,那么有人可以接管您的帐户。有什么问题吗 曾经使用 ScholarInterface 请发送电子邮件至 Rixhers Ajazi CoderRix@gmail.com有关您的帐户的任何问题,请 通知您的管理员。 Rixhers Ajazi 不是管理员,而是 超级用户(本程序的编码员)。

--B_ALT_520eb8d943598 内容类型:text/html; charset=utf-8 内容传输编码:quoted-printable

您好 Rixhers Ajazi,这是一封自动发送的电子邮件,用于通知您您的 acco= unt 已成功创建。您必须等待您的帐户 to be veri= fied 表示您无权使用 学术接口。 On= ce 您的帐户被激活并且您是 给定用户角色,您将通过电子邮件收到通知。请注意 既然您已经创建了您的帐户,那么您将负责 确保您的凭据安全。这些包括您的 em= ail 帐户, 您对安全问题的回答,以及您的密码 its= elf.I (Rixhers Ajazi) 只是想警告你,如果你不保持你的 se= curity 回答安全,然后有人可以接管您的帐户。任何 问题 = ScholarInterface 有什么问题,请发送电子邮件 Rixhers Ajazi at Cod= erRix@gmail.com关于您的任何问题 帐户请通知您的 = 管理员。 Rixhers Ajazi 不是 管理员但超级用户(该程序的 = 编码器)。

--B_ALT_520eb8d943598--

这是什么鬼?

这是我在 email.php 中的配置:

if ( ! defined('BASEPATH')) exit('No direct script access allowed');

 $config['protocol'] = 'smtp';
 $config['smtp_host'] = 'ssl://smtp.googlemail.com';
 $config['smtp_user'] = '********************@gmail.com';
 $config['smtp_pass'] = '**************************';
 $config['smtp_port'] = 465;
 $config['smtp_timeout'] = 30;
 $config['charset'] = 'utf-8';
 $config['crlf'] = "\r\n";
 $config['newline'] = "\r\n";
 $config['wordwrap'] = TRUE;
 $config['mailtype'] = 'html';

我在另一个应用程序中使用了相同的脚本,但我从来没有得到过这个。任何帮助都会很棒。

【问题讨论】:

  • 您说您在另一个应用程序中使用了相同的脚本...是服务器环境不同吗?您的日志中有任何伴随的错误吗?
  • 消息似乎是从主题标头开始的,所以我猜这是主题长度的问题。尝试再次提交电子邮件,主题应少于 75 个字符。

标签: php codeigniter email html-email


【解决方案1】:
Just add this in start of the function where you are writing send email code 
$config = Array(
          'protocol' => 'sendmail',
          'mailtype' => 'html', 
          'charset' => 'utf-8',
          'wordwrap' => TRUE

      );
     $this->email->initialize($config);
Email will forward but error same error will show

【讨论】:

    【解决方案2】:

    电子邮件顶部的消息似乎是从主题标头开始的,所以我想这将是一个开始调试的好地方。

    曾经有一个issue caused by Subject lines with more than 75 chars

    如果上述修复不起作用,那么开发人员已经修补了 Email.php 以解决问题:

    https://github.com/EllisLab/CodeIgniter/issues/1409#issuecomment-9330713

    【讨论】:

    • 非常感谢!这个答案为我指明了指向此链接的正确方向:stackoverflow.com/questions/8350865/…
    • 到目前为止,我还没有收到任何格式错误的电子邮件。
    • 谢谢你的链接和答案,一旦我缩短了我的 sublect 就像一个魅力
    猜你喜欢
    • 2013-04-18
    • 2013-01-07
    • 2019-08-07
    • 1970-01-01
    • 2017-07-08
    • 2014-07-13
    • 1970-01-01
    • 2012-12-16
    • 2015-04-09
    相关资源
    最近更新 更多