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

时间:2018-10-25 13:05:10

标签: php 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>";

            }

5 个答案:

答案 0 :(得分:0)

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

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

答案 1 :(得分:0)

请参阅此, https://www.codeigniter.com/user_guide/libraries/email.html

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

答案 2 :(得分:0)

签出Codeigniter官方文档以通过电子邮件发送附件。 Send Email With Attachments

答案 3 :(得分:0)

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

答案 4 :(得分:0)

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

$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');

您还可以使用URL:

$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');