CodeIgniter Forums
How to set email config different from 'mail', 'sendmail', or 'smtp' - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Development (https://forum.codeigniter.com/forumdisplay.php?fid=6)
+--- Forum: CodeIgniter 3.x (https://forum.codeigniter.com/forumdisplay.php?fid=17)
+--- Thread: How to set email config different from 'mail', 'sendmail', or 'smtp' (/showthread.php?tid=76706)



How to set email config different from 'mail', 'sendmail', or 'smtp' - peter.ashok - 06-11-2020

In one of my projects in CI, I need to use Amazon SDK API instead of Amazon SMTP. I have created a PHP file at "application/config" and add the following code to email.php. 

My Amazon SMTP configuration sending correct email but now as per my requirement, I need to change SMTP to SDK API.

I have searched many articles all showing CI email setup using SMTP in the configuration but not as SDK API using key & password.

My working SMTP configuration is shown below 

PHP Code:
$config['protocol']        = 'smtp'// 'mail', 'sendmail', or 'smtp'
$config['smtp_host']    = 'mtp.example.com';
$config['smtp_user']    = '[email protected]';
$config['smtp_pass']    = 'xxxxxxxxxx';
$config['smtp_crypto']    = 'tls';
$config['smtp_port']    = '587';
$config['mailtype']    = 'html';
$config['newline']    = "\r\n"

Please suggest how to replace this SMTP configuration with Amazon SDK so that I can use a secret key and password. Instead of SMTP details.


RE: How to set email config different from 'mail', 'sendmail', or 'smtp' - jreklund - 06-11-2020

Hi, you can't. It's to different protocols. You need to use their own PHP AWK SDK library to send emails. Or code your own with cURL, but that would take forever.


RE: How to set email config different from 'mail', 'sendmail', or 'smtp' - peter.ashok - 06-11-2020

(06-11-2020, 10:44 AM)jreklund Wrote: Hi, you can't. It's to different protocols. You need to use their own PHP AWK SDK library to send emails. Or code your own with cURL, but that would take forever.


Thanks, I have created my own custom library and used my custom library function instead of CI $this->email->send() function. It is working fine I have followed Amazon documentation at https://docs.aws.amazon.com/ses/latest/DeveloperGuide/send-using-sdk-php.html

I
n my controllers, I have replaced $this->email->send() call with my new $SesClient->sendEmail() function.  In my project earlier developer has used ION Auth so when any new user register himself he will receive an account activation email that is not in any controller but ION auth library to send an email. When I looked into the code I found that ION Auth using CI default email feature set in the configuration. This is the reason I am looking for a solution so that it will work ION Auth send Activation email or Resend Activation email as well. Please suggest. Do I need to modify Ion_auth library  or there is an alternative correct way?


RE: How to set email config different from 'mail', 'sendmail', or 'smtp' - jreklund - 06-12-2020

You will need to modify or extend ion auth. I'm not quite sure you can extend/replace Codeigniters own mail function.


RE: How to set email config different from 'mail', 'sendmail', or 'smtp' - dave friend - 06-14-2020

I would modify Ion_auth to use the custom library.