php框架codeigniter发送邮件带附件的例子

发布时间:2020-07-19编辑:脚本学堂
本文介绍了php框架odeigniter发送邮件的例子,codeigniter的邮件发送支持哪些特性,并提供了一个codeigniter实现发送带附件的邮件的例子。

codeigniter框架发送邮件的方法,重点看下如何发送带了附件的邮件。

一、codeigniter发送邮件的方法。

codeigniter的邮件发送支持以下特性:
 

multiple protocols: mail, sendmail, and smtp
multiple recipients
cc and bccs
html or plaintext email
attachments
word wrapping
priorities
bcc batch mode, enabling large email lists to be broken into small bcc batches.
email debugging tools

例子:
 

复制代码 代码示例:
$this->load->library('email');
$this->email->from('w3@w3mentor.com', 'w3m');
$this->email->subject('email test');
$this->email->message('testing the email class in codeigniter.');
$this->email->send();

二、codeigniter实现发送带附件的邮件

codeigniter实现发送带附件的邮件的方法

attach() 方法允许你的发邮件时带上附件

例子:
 

复制代码 代码示例:
$this->load->library('email');
$this->email->from('w3@w3mentor.com', 'w3m');
$this->email->subject('email test with attachment');
$this->email->message('testing the email class in codeigniter with attachment.');
$this->email->attach('/path/to/attachment1.jpg');
$this->email->send();