Codeigniter use email for SMTP mail sending Method

Source: Internet
Author: User
Tags codeigniter
Cause:

When using codeigniter, we often need to send emails to remind ourselves or notify others. At this time, we can use the class email provided by codeigniter to complete our work.

Introduction:

By viewing the email. php file, we can see that codeigniter can use three Protocols to send Emails:

VaR $ protocol = "mail"; // mail/sendmail/SMTP

We use SMTP here.

Usage:

First, select email. I chose Google's Gmail here. Gmail is generally not considered as spam, but Gmail's SMTP method is SSL, therefore, SSL must be installed on the host before it can be used.

$config['protocol']     = 'smtp';$config['smtp_host']    = 'ssl://smtp.gmail.com';$config['smtp_user']    = 'youremail@gmail.com';$config['smtp_pass']    = 'yourpassword';$config['smtp_port']    = '465';$config['charset']      = 'utf-8';$config['mailtype']     = 'text';$config['smtp_timeout'] = '5';$config['newline'] = "\r\n";$this->load->library ('email', $config);$this->email->from ('from@email.com', 'From email name');$this->email->to ('to@email.com', 'To email name');$this->email->bcc ('bcc@email.com');$this->email->subject ('Test subject');$this->email->message ('The content');$this->email->send ();

Run the following command to check whether the job works:

echo $this->email->print_debugger();exit;

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.