I'm sending Newsletter templates to my subscribers using wp_mail function. I am simply retrieving my subscribers list from my db and passing it in wp_mail function as an array as $to. Now the problem is, I want to add unsubscribe link to my emailer. All I want to achieve is a way to add reciever's email address in my unsubscription's hyperlink as a parameter so that i can use it for unsubscription. i.e www.mysiteurl.com/?user_email=useremail@domain.in
//php code
ob_start();
//including newsletter template
include '/newsletter-template.php';
$message = ob_get_contents();
ob_end_clean();
//adding filter to allow <html> tags in message body
add_filter( 'wp_mail_content_type', 'newsletter_content_type' );
@wp_mail( $subscriberListArray, 'Testing Newsletter', $message, 'From: myWebsite <newsletter@myWebsite.com>' );
//removing <html> tags filter once mail is sent
remove_filter( 'wp_mail_content_type', 'newsletter_content_type' );
//html part
<div>
<a href="www.mysiteurl.com/?user_email={dynamic_value}">unsubscribe</a>
</div>
above codes are working fine but i want to insert email of the current subscriber in my template file. is there any way to doing this? thank you.