how to configure SMTP in codeigniter application?

谁说我不能喝 提交于 2020-01-07 04:11:12

问题


I'm new to SMTP, sendmail, and mail() function in php codeigniter.

I'm trying to configure SMTP mail protocol in my codeigniter application. Make all settings, SMTP port, sender mail, user id, password for single user i.e. admin@example.com. It working fine.

My question is, it is possible to setup two SMTP user account in single application ?

For example I want to set info@example.com and admin@example.com, so these two users can send mails to customers.


回答1:


You can use it by only changes in config : as like

$config = Array(
    'protocol' => 'smtp',
    'smtp_host' => 'ssl://smtp.googlemail.com',
    'smtp_port' => 465,
    'smtp_user' => 'xxx', // First user authenticate
    'smtp_pass' => 'xxx',
    'mailtype'  => 'html', 
    'charset'   => 'iso-8859-1'
);
$this->load->library('email', $config);
$this->email->set_newline("\r\n");

// Set to, from, message, etc.

$result = $this->email->send();

and

$config = Array(
    'protocol' => 'smtp',
    'smtp_host' => 'ssl://smtp.googlemail.com',
    'smtp_port' => 465,
    'smtp_user' => 'yyy', // Second user authenticate
    'smtp_pass' => 'zzzz',
    'mailtype'  => 'html', 
    'charset'   => 'iso-8859-1'
);
$this->load->library('email', $config);
$this->email->set_newline("\r\n");

// Set to, from, message, etc.

$result = $this->email->send();

But only one thing is that you have to configure your both mail user at server. Thanks



来源:https://stackoverflow.com/questions/41973704/how-to-configure-smtp-in-codeigniter-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!