Send Email With CodeIgniter

Send your email forwarding from guestbook maybe or ticketing support with CodeIgniter Email Library or using third party server.
case if using Mandrill
Sending Email from CodeIgniter with Mandrill
The last time I used CodeIgniter in my project was about two years ago. It was an online property marketplace where people can collectively buy expensive houses by sharing ownership of the house and, of course, sharing the mortgage. There was these times when I had my dead-end building an application module to send email to customers, some sort of news letter. The dead-end was actually due to google SMTP limitation on relaying email from my application. If you are on a project that still rely on Google's SMTP to send email, I suggest you migrate to Mandrill.
Mandrill is a transactional email platform from MailChimp. By definition Mandrill is a transactional email platform, which can use to relay emails from our application. Of course there is a price for their services, but as long as we are sending less than 12,000 emails per month we are eligible for free services. It is easy though to scale up if we need to send more than 12,000 emails in a month. Just upgrade your package without re-signing-up your account.
CodeIgniter Mail Library

In order to get our mailing module work, we need to register to mandrill to get our SMTP credentials. To do so, go ahead and open your favorite browser (mine is Chrome) and enter at the address bar.
Click the Sign Up button to create a new account on Mandrill. This is very easy because all you need to fill is just your email address and your Mandrill password. Note that your mandrill password is not your SMTP password.
After signing up, there is going to be an optional profile form that you may or may not fill. I will skip this form for now by clicking the No, Thanks button on the left bottom of the form.
Next step is to click the Get SMTP Credentials button.
 And then type in your Mandrill password when prompted.
Mandrill will create and display your SMTP account detail afterward. Now, to get your SMTP password, click on the + Add API Key button below your SMTP credentials.
Up to this point you should see a new API key. This key (or one of these keys, if you have more than one) can be your SMTP password.
Go on and replace those hash-tags on our email configuration. Go to directoryapplication/config/ and open file email.php, then edit the file matching your Mandrill SMTP credentials.
$config['smtp_host'] = '';
$config['smtp_user'] = '';
$config['smtp_pass'] = 'th1s-1s-y0ur-p4ssw0rd!';
$config['smtp_port'] = '587';
That's it!
Now try to run your script on your browser, and give a comment below if you're having trouble. By the way, to prove you that this tutorial works (even from http://localhost setup on your computer), this what it looks like when I checked my email:
Sample script on Controller Mandrill ThirdParty :

Sample script on Controller with Email Library CI :

note :
If you used Codeigniter, Library can colaborate automatically with config at folder application/config just with 1 condition = file name of library n config is same. If you used hosting for your app or app is gone public, please check your setting on server hosting to combine/allowed port that used (465 google or 587 mandrill)

Share this

Related Posts

Next Post »