Sending multiple email from codeigniter

好久不见. 提交于 2020-01-02 21:10:14

问题


Hi friends i am creating newsletter in codeigniter. Is there a way to send multiple email with CI email lib or should i use third party ?


回答1:


Using the Email Class, something like:

foreach ($list as $name => $address)
{
    $this->email->clear();

    $this->email->to($address);
    $this->email->from('your@example.com');
    $this->email->subject('Here is your info '.$name);
    $this->email->message('Hi '.$name.' Here is the info you requested.');
    $this->email->send();
}

would work. (Straight from the docs). It depends on how many addresses you have, and any constraints such as server/mail queue processing/script time out etc

I'm not personally aware of a 3rd party CI newsletter plugin/library but i haven't looked too hard.




回答2:


Straight from the manual…

$this->email->to() 

Sets the email address(s) of the recipient(s). Can be a single email, a comma-delimited list or an array:

$this->email->to('someone@example.com'); 
$this->email->to('one@example.com, two@example.com, three@example.com'); 
$list = array('one@example.com', 'two@example.com', 'three@example.com');
$this->email->to($list); 


来源:https://stackoverflow.com/questions/3888745/sending-multiple-email-from-codeigniter

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