Skip Navigation

[Resolved] cannot send email with bcc

This support ticket is created 5 years, 8 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 2 replies, has 2 voices.

Last updated by nabils 5 years, 8 months ago.

Assisted by: Luo Yang.

Author
Posts
#1249037

Dear,
This is a follow-up of ticket:
https://toolset.com/forums/topic/send-email-notification-to-all-users-of-a-certain-role/
in:
add_filter('cred_notification_recipients', 'send_subscribed_users_func', 10, 4);
function send_subscribed_users_func($recipients, $notification, $form_id, $post_id){
if ( 29015 == $form_id){
$args = array('meta_key'=> 'wpcf-notification-offer-program', 'meta_value' => 1, 'fields' => array( 'display_name', 'user_email') );
$users = get_users( $args );
foreach($users as $user){

$recipients[] = array('to' => 'to', 'address' => $user->user_email, 'display_name' => $user->display_name );

}
etc.
This works perfectly.
Now I want to end this email with "bcc" option. I tried adding to the recipients one "to" (my own email) and the other users in bcc, but the email went only to the "to", not the emails in bcc. For example, in the code below, email goes only to first email:
//$recipients[] = array('to' => 'to', 'address' => "na76@gmail.com", 'display_name' => "nabil" );
//$recipients[] = array('Bcc' => 'Bcc', 'address' => "nabil@mail.com", 'display_name' => "bcc" );

Thank you for helping

Nabil

#1249099

Hello,

You can try this, modify this line from:

$recipients[] = array('to'	=> 'to', 'address' => $user->user_email, 'display_name' => $user->display_name );

To:

$recipients[] = array('to'	=> 'bcc', 'address' => $user->user_email, 'display_name' => $user->display_name );

See our document:
https://toolset.com/documentation/programmer-reference/cred-api/#cred_notification_recipients

click link "Usage examples", there is a similar example codes as your case.

#1249809

My issue is resolved now. Thank you!