繁体   English   中英

如何在codeigniter中发送带有附件文件的电子邮件

[英]how to send email with attchment file in codeigniter

如何发送带有附件文件的电子邮件。 例如我尝试附加模板

$arr['email']="Email send successfully";

                 $this->email->from("Info@.com","example@gmail.com");
                 $this->email->to(set_value("email")); 
                 $this->email->subject("Registration completed");
                 $this->email->message("Your Registration Is Completed");
                 $this->email->send(); 
                 echo "<script> alert('Your Registration successfully');</script>";

            }

https://www.codeigniter.com/user_guide/libraries/email.html

您可以关注codeigniter的官方网站。

请参考https://www.codeigniter.com/user_guide/libraries/email.html

请按照同一页面下面的“发送电子邮件”部分进行操作。

签出Codeigniter官方文档以通过电子邮件发送附件。 发送带有附件的电子邮件

使用$this->email->attach('path_to_your_file'); 与您的代码组合。 它会工作。

使您可以发送附件。 将文件路径/名称放在第一个参数中。 对于多个附件,请多次使用该方法。 例如:

$this->email->attach('/path/to/photo1.jpg');
$this->email->attach('/path/to/photo2.jpg');
$this->email->attach('/path/to/photo3.jpg');

要使用默认配置(附件),请将第二个参数留空,否则请使用自定义配置:

$this->email->attach('img.jpg', 'inline');

您也可以使用以下网址:

$this->email->attach('http://example.com/filename.pdf');

如果要使用自定义文件名,则可以使用第三个参数:

$this->email->attach('filename.pdf', 'attachment', 'file.pdf');

如果您需要使用缓冲字符串而不是实际文件,则可以将第一个参数用作缓冲区,将第三个参数用作文件名,第四个参数用作mime-type:

$this->email->attach($buffer, 'attachment', 'report.pdf', 'application/pdf');

暂无
暂无

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

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