CodeIgniter send mail (smtp)

Source: Internet
Author: User
Tags codeigniter
$ This-& gt; load-& gt; library (& amp; #39; email & amp; #39;); $ config [& amp; #39; protocol & amp; #39;] & amp; #39; smtp & amp; #39; // send it to QQ users for Chinese use & amp; #39; ISO-8859-1 & amp; #39; $ c

$ This-> load-> library ('email ');


$ Config ['protocol'] = 'smtp ';
// Send it to the QQ user and use 'ISO-8859-1 'to display Chinese characters'
$ Config ['charset'] = 'ISO-8859-1 ';
// Send the message to 163 users. use 'gb2312' to display Chinese characters'
// $ Config ['charset'] = 'gb2312 ';
$ Config ['mailpath'] = 'news/index ';
$ Config ['smtp _ host'] = 'smtp .163.com ';
$ Config ['smtp _ user'] = 'example0624 @ 163.com ';
$ Config ['smtp _ pass'] = 'password ';

$ This-> email-> initialize ($ config );

$ This-> email-> from ('example0624 @ 163.com ', 'example ');
$ This-> email-> to ('tosombody @ qq.com ');
// Set CC to www.2cto.com
// $ This-> email-> cc ();
// Set to send messages in the dark
// $ This-> email-> bcc ();
$ This-> email-> subject ("The test of CodeIgniter's sending mail ");
$ This-> email-> message ('Hi, this is my test program. Do not reply to emails sent successfully through CodeIgniter. ');
// The path must use an absolute path.
$ This-> email-> attach ('d:/QCallServer/htdocs/CI/public/images/google.jpg ');
If ($ this-> email-> send ()){

Echo 'success ...';
} Else {
Echo 'failed ...';
}

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.