-
-
Save nkb-bd/be01308b91cd7e0ece38d2ad7ca1cebc to your computer and use it in GitHub Desktop.
email from localhost via smtp server on codeigniter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Load email library | |
$this->load->library('email'); | |
//SMTP & mail configuration | |
$config = array( | |
'protocol' => 'smtp', | |
'smtp_host' => 'ssl://smtp.googlemail.com', | |
'smtp_port' => 465, | |
'smtp_user' => '[email protected]', | |
'smtp_pass' => 'gmail_password', | |
'mailtype' => 'html', | |
'charset' => 'utf-8' | |
); | |
$this->email->initialize($config); | |
$this->email->set_mailtype("html"); | |
$this->email->set_newline("\r\n"); | |
//Email content | |
$htmlContent = '<h1>Sending email via SMTP server</h1>'; | |
$htmlContent .= '<p>This email has sent via SMTP server from CodeIgniter application.</p>'; | |
$this->email->to('[email protected]'); | |
$this->email->from('[email protected]','MyWebsite'); | |
$this->email->subject('How to send email via SMTP server in CodeIgniter'); | |
$this->email->message($htmlContent); | |
//Send email | |
$this->email->send(); | |
/////////////////////////////$this->load->library('encrypt');///////////to avoid spamming of mail//////////////////////// | |
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
////CHANGE SETTINGS IN GOGLE ACCOUNTS///// | |
////MY ACCOUNT>SIGNING IN TO GOOGLE(under sign in & security)///// | |
////SWITCH OFF 2 STEP VERIFICATION///// | |
////IN CONNECTED APPS N SITES>SWITCH ONN---"ALLOW LESS SECURE APPS"----///// | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment