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

Php 如何在codeigniter中发送带有附件文件的电子邮件,php,codeigniter,Php,Codeigniter,如何发送带有附件文件的电子邮件。例如,我尝试附加模板 $arr['email']="Email send successfully"; $this->email->from("Info@.com","example@gmail.com"); $this->email->to(set_value("email")); $this->email->subjec

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

$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>";

            }
$arr['email']=“电子邮件发送成功”;
$this->email->from(“Info@.com","example@gmail.com");
$this->email->to(设置_值(“email”);
$this->email->subject(“注册完成”);
$this->email->message(“您的注册已完成”);
$this->email->send();
回显“警报(‘您的注册成功’);”;
}

您可以访问codeigniter的官方网站。

请参考此,


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

查看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');
您还可以使用URL:

$this->email->attach('http://example.com/filename.pdf');
如果要使用自定义文件名,可以使用第三个参数:

$this->email->attach('filename.pdf', 'attachment', 'file.pdf');
如果需要使用缓冲区字符串而不是实际物理文件,则可以使用第一个参数作为缓冲区,第三个参数作为文件名,第四个参数作为mime类型:

$this->email->attach($buffer, 'attachment', 'report.pdf', 'application/pdf');
可能重复的