Codeigniter supported inbuilt Email library class which simplify the email sending process. To send email we need to do some configuration , need to load email library.codeigniter supports Multiple Protocols, Mail, Sendmail, and SMTP, Multiple recipients, CC and BCCs,HTML or Plain text email, Attachments ,Word wrapping and many more.
Lets start with Codeigniter email configurations. Here I have used gmail as smtp server.
$this->load->library('email');
// Email configuration
$config = Array(
'protocol' => 'smtp',
'smtp_host' => 'ssl://smtp.googlemail.com',
'smtp_port' => 465,
'smtp_user' => 'senders_email_address',
'smtp_pass' => '********', //Password of senders email
'mailtype' => 'html',
'charset' => 'iso-8859-1'
);
Now, we can send the email with above configurations.
$this->load->library('email', $config);
$this->email->set_newline("\r\n");
$this->email->from('senders_email', 'name_of_the_sender');
$this->email->to('reciever's_mail_address');
$this->email->cc('');
$this->email->bcc('');
$this->email->subject('subject_of_the_mail');
$this->email->message('message_body');
$this->email->send();
Now, we can send the email with above configurations.
$this->load->library('email', $config);
$this->email->set_newline("\r\n");
$this->email->from('senders_email', 'name_of_the_sender');
$this->email->to('reciever's_mail_address');
$this->email->cc('');
$this->email->bcc('');
$this->email->subject('subject_of_the_mail');
$this->email->message('message_body');
$this->email->send();
Comments
Post a Comment