我有一个从Wordpress数据库中获取的电子邮件列表。
我想使用联系人表单7以编程方式向这些电子邮件发送电子邮件。
这是我的密码
function benson_call_before_form_submit( $wpcf7 ){
$submission = WPCF7_Submission::get_instance();
if ( $submission ) {
$posted_data = $submission->get_posted_data();
}
if( $wpcf7->id() == 2216 || $wpcf7->id() == "2216" ) {
//$wpcf->skip_mail = true;
// we can now send the email here
$emails = get_mod_and_admin_emails(); // these are emails
// how do I send email inside here from contact form 7
// ?????????????????
}
}
add_action( \'wpcf7_before_send_mail\', \'benson_call_before_form_submit\' );
function get_mod_and_admin_emails( ){
global $bp;
$users = get_users( array( \'fields\' => array( \'ID\', \'user_email\' ) ) );
$emails = "";
foreach($users as $key => $user){
$user_id = $user->ID;
if( groups_is_user_mod( $user_id, $bp->groups->current_group->id ) || groups_is_user_admin( $user_id, $bp->groups->current_group->id ) ){
$email = $user->user_email;
$emails .=$email.",";
}
}
return $emails;
}