如何使用 PHP(Codeigniter) 群发邮件?
How to send bulk emails using PHP(Codeigniter)?
请告诉我如何使用 php Codeigniter 发送多封电子邮件。
public function send_spam($to_address){
$this->load->library('email');
$message = 'some stuff, some files, some whatever';
$this->email->clear();
$this->email->from('spam@spam.com);
$this->email->reply_to('noreply@spam.com);
$this->email->to($to_address);
$this->email->subject('DAT SPAM YO');
$this->email->message($message);
if($this->email->send()===TRUE){
return true
}
return false;
}
$emails = array('victim1@victim.com', 'victim2@victim.com');
foreach($emails as $victim){
$this->send_spam($victim)
}
切勿将自己的服务器用于群发电子邮件,如果您使用的是 vps,提供商可能有垃圾邮件过滤器,如果不是 vps 主机,您最终会收到电子邮件,那么客户可能会将您的电子邮件标记为垃圾邮件阅读更多关于 ANTI SPAM here
解决方案
使用第三方电子邮件服务 api,例如 mailshimp,您可以使用免费帐户做很多事情,他们会给您一个免费密钥,您可以使用他们的 api
https://apidocs.mailchimp.com/api/example-code/
示例:
假设您的 api 键是 kisaragi2015
$key = "kisaragi2015"
并且您在 mailshimp 上有一个 id = 123 的预先准备好的活动
$cid = 123
你直接这样发送就可以了
send($key, $cid) ;
就是这样,详情请看文档
https://mandrillapp.com/api/docs/
有 other email service,但这取决于您选择最适合您的需要
希望对您有所帮助!
您可以像这样将多个电子邮件作为数组传递:
$more_email = array('one@example.com', 'two@example.com', 'three@example.com');
$this->email->to($more_email);
$this->email->send()
请告诉我如何使用 php Codeigniter 发送多封电子邮件。
public function send_spam($to_address){
$this->load->library('email');
$message = 'some stuff, some files, some whatever';
$this->email->clear();
$this->email->from('spam@spam.com);
$this->email->reply_to('noreply@spam.com);
$this->email->to($to_address);
$this->email->subject('DAT SPAM YO');
$this->email->message($message);
if($this->email->send()===TRUE){
return true
}
return false;
}
$emails = array('victim1@victim.com', 'victim2@victim.com');
foreach($emails as $victim){
$this->send_spam($victim)
}
切勿将自己的服务器用于群发电子邮件,如果您使用的是 vps,提供商可能有垃圾邮件过滤器,如果不是 vps 主机,您最终会收到电子邮件,那么客户可能会将您的电子邮件标记为垃圾邮件阅读更多关于 ANTI SPAM here
解决方案
使用第三方电子邮件服务 api,例如 mailshimp,您可以使用免费帐户做很多事情,他们会给您一个免费密钥,您可以使用他们的 api https://apidocs.mailchimp.com/api/example-code/
示例: 假设您的 api 键是 kisaragi2015
$key = "kisaragi2015"
并且您在 mailshimp 上有一个 id = 123 的预先准备好的活动
$cid = 123
你直接这样发送就可以了
send($key, $cid) ;
就是这样,详情请看文档
https://mandrillapp.com/api/docs/
有 other email service,但这取决于您选择最适合您的需要
希望对您有所帮助!
您可以像这样将多个电子邮件作为数组传递:
$more_email = array('one@example.com', 'two@example.com', 'three@example.com');
$this->email->to($more_email);
$this->email->send()