【问题标题】:Mail message/attachment is not showing up邮件消息/附件未显示
【发布时间】:2011-03-29 21:00:30
【问题描述】:

我正在使用 codeigniter 发送邮件。它工作正常,但有这个奇怪的问题。邮件将发送给收件人并显示主题。但它不会显示消息和附件。

这里是代码。我认为这是一个我无法检测到的愚蠢错误。帮帮我!

//configure email settings
    $config = array(
        'protocol'=>'smtp',
        'smtp_host'=> 'ssl://smtp.gmail.com',
        'smtp_port'=>'465',
        'smtp_user'=>'xxxxxxxxxxxxxxxx',
        'smtp_pass'=>'xxxxxxxxxxxxxxxx',

    );

    $this->load->library('email',$config);
    $this->email->set_newline("\r\n");
    $this->email->from('xxxxx@gmail.com','myname');
    $this->email->to($email);
    $this->email->subject('Test');
    $this->email->message('It works!');

    //attach newsletter to email
    $path=$this->config->item('server root');
    $file=$path . '/codeigniter/attachments/newsletter.txt';
    $this->email->attach($file);

    if($this->email->send())
    {
        echo "your email was sent";
    }
    else
    {
        show_error($this->email->print_debugger());
    }

【问题讨论】:

  • 不应该在$config 数组中将新行值定义为'newline' => "\r\n" 吗?您能看到收到的电子邮件的来源(例如 Thunderbird)及其大小以与附件大小和邮件其余部分的一些字节进行比较吗?

标签: php email codeigniter gmail


【解决方案1】:

尝试将 set_newline 更改为:

$this->email->set_newline("\n");

我过去也遇到过类似的问题,这为我解决了问题。

【讨论】:

    猜你喜欢
    • 2015-09-09
    • 2013-10-30
    • 1970-01-01
    • 2011-01-16
    • 2021-04-06
    • 2016-01-03
    • 2014-10-30
    • 1970-01-01
    • 2020-06-03
    相关资源
    最近更新 更多