PHP发送回复后发送电子邮件

时间:2014-08-04 19:46:12

标签: php html

我的php代码中有函数:

foreach ($myarray as $customer) {
     //doing some code
     $this->sendMail($this->attachedfiles,$customer);
}

$this->response($this->success);

此代码循环遍历数组,并向每个attachedfiles发送电子邮件,并最终回复客户端。

这个问题是需要花费很多时间。所以我尝试了这样的事情:

$customer_email = array();
$customer_attachedfiles = array();

foreach ($myarray as $customer) {
     array_push($customer_email, $customer);
     array_push($customer_attachedfiles, $this->attachedfiles);
}

$this->response($this->success);

$indextmp = 0; 
foreach ($customer_email as $customer2) {
     $attachedfiles_tmp = $customer_attachedfiles($indextmp);
     $this->sendMail($attachedfiles_tmp,$customer2);
     $indextmp++;
}

并且以这种格式发送邮件,不知道会出现什么问题?

1 个答案:

答案 0 :(得分:1)

您可以使用Swift Mailer或PHPMailer。 使用此库,您可以通过一个操作轻松地将邮件发送到许多电子邮件。 http://swiftmailer.org/docs/introduction.html