I would like to send some extra information on the emails which is sent from codeigniter library. Is there any way to configure or add this?
I want to categorize all the outgoing mail from my site. I need to include sendgrid category header for tracking.
Alright, I just want to improve the best answer here. Credit goes to @Tekniskt, and the only difference here is that the settings you might have in /application/config/email.php are ignored, which hurts, especially if you are using custom STMP settings.
Here's the full code of the class MY_Email.php I've improved from the answer above:
Hope it helps! :)
I did my test, and it seems now /config/email.php is included and settings are passed properly.
Cheers and thanks for the answer! :)
Pass the
$config
parameterSet custom header as
The CodeIgniter email class doesn't let you manually set headers. However you could change this by extending it and adding a new function that allows you to set the sendgrid headers.
See the "Extending Native Libraries" section of the CodeIgniter manual:
https://www.codeigniter.com/user_guide/general/creating_libraries.html
Here's what the code in your new email class might look like.
You'd then be able to set headers using your new email class like this:
This page will explain what headers can be passed to SendGrid: http://sendgrid.com/docs/API%20Reference/SMTP%20API/