【问题标题】:send email with attach file saved in server folder | codeigniter发送带有保存在服务器文件夹中的附件的电子邮件 |代码点火器
【发布时间】:2019-11-20 22:46:29
【问题描述】:

我正在尝试发送带有保存在服务器文件夹中的附件的电子邮件,电子邮件发送成功,但在发送的电子邮件中看不到文件

如何获取保存在服务器中的文件路径?

          $this->load->library('email');
         $this->load->helper('file');
         $this->email->set_mailtype("html");
         $this->email->from($fromEmail, $fromEmailName);
         $this->email->to($toEmail);
         $this->email->subject($emailSubject);

$message = '<p> confirm </p> <img src="cid:logo" width="80" height="80" />'; // here src id 

$file_name = "file.jpeg";

$file_url= base_url()."/uploads/".$file_name;

$this->email->attach($file_url , 'logo' , 'inline' ); // here when add the src id not work

【问题讨论】:

标签: codeigniter


【解决方案1】:

很可能您的文件地址可能有误。再次检查文件名。

如果这不起作用,请尝试这样的操作。

  $file_url= $_SERVER["DOCUMENT_ROOT"]."/uploads/".$file_name;
  $this->email->attach($file_url);

或者研究以下与您的问题相似的问题的答案。

answer 1

【讨论】:

  • 我知道的路径有问题,但你的路径又不适合我
  • 你的文件名是“5.jpeg”吗?
  • 当我输入 src 名称和内联时看到这里我会更新我的 Q
  • 回显$file_url并检查是否可以在浏览器中打开
  • 像这样工作---- $message = '

    确认

    ';----- 但我不想这样,因为接收者必须点击查看所有电子邮件正文才能显示图像,所以我必须用户嵌入图像
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2012-08-01
  • 1970-01-01
  • 2013-08-18
  • 2015-07-26
  • 2011-04-18
  • 2016-02-12
  • 1970-01-01
相关资源
最近更新 更多