Send CI to email (attachments can be sent)

Source: Internet
Author: User
Tags email account

Public function sendMail (){
$ Config ['protocol'] = 'smtp '; // use smtp

$ Config ['smtp _ host'] = 'smtp .126.com ';
$ Config ['smtp _ user'] = 'mytest @ 126.com '; // your email account
$ Config ['smtp _ pass'] = 'mytest123'; // your email password



// $ Config ['smtp _ pass'] = 25;
$ Config ['charset'] = 'utf-8 ';
$ Config ['wordwre'] = TRUE;
$ Config ['mailtype'] = "html ";
$ This-> load-> library ('email '); // load the email class
$ This-> email-> initialize ($ config); // parameter configuration
$ This-> email-> from ('lijun%19862008 @ 126.com ', 'am the sender Chen Liwei ');

$ This-> email-> to ('My @ test.com ');
// $ This-> email-> cc ('another @ another-example.com ');
// $ This-> email-> bcc ('them @ their-example.com ');

$ This-> email-> subject ('email Test to guijia ');

$ This-> email-> message ('testing the email class .');

$ This-> email-> attach ('static/upfile/'. $ sfile .'');

// Display the email sending result and load it to the res_view.php View File.
If (! $ This-> email-> send ()){
$ Data = "<font color = 'red' size = '10px '> email sending failed, possibly because your sender or password does not match </font> ";

} Else {
$ Data = "<font color = 'red' size = '10px '> email sent successfully </font> ";

}
Echo $ data;
Echo $ this-> email-> print_debugger ();

}


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.