Codeigniter-使用Codeigniter电子邮件库,如何将电子邮件发送到数据库列表? [英] Codeigniter - Using codeigniter email library, how do i send the email to a database list?

查看:70
本文介绍了Codeigniter-使用Codeigniter电子邮件库,如何将电子邮件发送到数据库列表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,当使用codeigniters电子邮件类时,我意识到发送到一封电子邮件是有效的;

So when using codeigniters email class i realise that sending to a single email is;

    $this->email->to('email1@email.com');

并发送至多封电子邮件,如下所示;

and to multiple emails is an array like below;

    this->email->to('one@example.com, two@example.com, three@example.com');

但是我如何向存储在数据库中的联系人列表发送电子邮件。联系人表电子邮件字段..这可能吗?如果是的话,我该如何设置u-?我是否使用模型等?我是codeingiter的新手,所以如果这样做很简单,就可以省事了。

But how do i send an email to a list of contacts stored in a database, say.. 'contacts' table 'email' field.. is this possible? and if so how do i set it u-? do i use a model etc etc? im new to codeingiter so apoligies if this is simple

推荐答案

没有db表到电子邮件的本地映射,因此您必须首先选择,然后检索然后发送

There is no native mapping of db table to email, so you have to first select, then retrieve then send

$query = $this->db->query("SELECT emailAddress from table"); //select email addresses
$sendTo=array();
foreach ($query->result() as $row) //loop to build array
{
    $sendTo[]=$row->emailAddress; //add to array
}

$this->email->to($sendTo);//send email 

当然,我不得不猜测您是否有表格电子邮件字段。另一个(更好?)选项是将发送放入循环中,因此您可以分别发送到每个电子邮件地址。

Of course I have had to guess you tables email field. The other(better?) option would be to put the send in to the loop, so you send to each email address separately.

这篇关于Codeigniter-使用Codeigniter电子邮件库,如何将电子邮件发送到数据库列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆