我正在尝试向所有用户发送自定义事件的电子邮件。为此,我编写了以下代码,但它无法正常工作。我究竟做错了什么?
//send mail to all users
$result= $wpdb->get_var( $wpdb->prepare("SELECT user_email FROM $table_users"));
foreach($result as $email) {
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
$headers.= "From:mysite<[email protected]>\r\n";
$message = "<b>Dear! user</b>,<br/><br/> A new share is available to purchase
for amount $".$sellamt."<br>this is an automated mail.pls don't reply to this mail. ";
$send=mail($email,"mysite:New share Available to Purchase!",$message,$headers);
}
header('Location: /offer_csuccess');
exit();
获取所有用户功能get_users();
$all_users = get_users();
foreach ($all_users as $user) {
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
$headers.= "From:mysite<[email protected]>\r\n";
$message = "<b>Dear! user</b>,<br/><br/> A new share is available to purchase
for amount $".$sellamt."<br>this is an automated mail.pls don't reply to this mail. ";
$send=mail($user->user_email,"mysite:New share Available to Purchase!",$message,$headers);
}
exit();