Hi Takayuki, thank you for getting back to me. I’m sorry that I could not get back to this. There were other projects that required my urgent attention. Here is the whole function (I had to replace the name of the website with “…” because there is a non-disclosure contract in place)
add_action(‘wpcf7_before_send_mail’, ‘my_wpcf7_before_send_mail’);
function my_wpcf7_before_send_mail($form) {
$wpcf7_data->skip_mail = true;
$submission = WPCF7_Submission::get_instance();
if ($submission){
$posted_data = $submission->get_posted_data();
}
if ($posted_data[‘send_on’]== date(“m/d/Y”)){
// Card does not have to be scheduled
$recipient1=$posted_data[‘recipient1’];
$recipient2=$posted_data[‘recipient2’];
$recipient3=$posted_data[‘recipient3’];
$recipient4=$posted_data[‘recipient4’];
$recipient5=$posted_data[‘recipient5’];
$hashfield=$posted_data[‘hashfield’];
$user_email=$posted_data[‘user_email’];
$sender_name=stripslashes($posted_data[‘sender_name’]);
$subject=$sender_name . ” has sent you an e-card.”;
$mime_boundary = “—-… e-Cards—-“.md5(time());
$headers = “From: … e-Cards <ecard@….com>\r\n”;
$headers .= “Reply-To: … e-Cards <ecard@….com>\r\n”;
$headers .= “MIME-Version: 1.0\r\n”;
$headers .= “Content-Type: multipart/alternative; boundary=\”$mime_boundary\”\r\n”;
$email_part1 .=”
<html>
<head>
<meta http-equiv=’content-type’ content=’text/html; charset=windows-1250′>
<meta name=’generator’ content=’PSPad editor, https://www.pspad.com’>
<title></title>
</head>
<body>
<div style=’background-color:#3a7f7b;’>
<!–[if gte mso 9]>
<v:background xmlns:v=’urn:schemas-microsoft-com:vml’ fill=’t’>
<v:fill type=’tile’ src='”.get_bloginfo(‘home’).”/wp-content/themes/…/images/email_pattern.jpg’ color=’#3a7f7b’/>
</v:background>
<![endif]–>
<table height=’100%’ width=’100%’ cellpadding=’0′ cellspacing=’0′ border=’0′>
<tr>
<td valign=’top’ background='”.get_bloginfo(‘home’).”/wp-content/themes/…/images/email_pattern.jpg’>
<table width=’600′ cellpadding=’10’ cellspacing=’0′ style=’border:10px solid #FFFFFF;margin-top:50px;’ align=’center’ border=’0′>
<tr>
<td>
<table width=’100%’ cellpadding=’20’ cellspacing=’0′ border=’0′ bgcolor=’#FFFFFF’>
<tr>
<td style=’padding:15px;’ align=’center’>
<img src='”.get_bloginfo(‘home’).”/wp-content/themes/…/images/logo_email.jpg’ alt=’…’/>
</td>
</tr><tr>
<td align=’center’>
<p><font face=’Times New Roman, Georgia, serif’ size=’4′>“.$sender_name.”</font> <font face=’Arial, Helvetica, Verdana, sans-serif’ size=’3′>(“;
$email_part2=”)</font> <font face=’Times New Roman, Georgia, serif’ size=’4′> has sent you a … e-card.</font></p>
</td>
</tr><tr>
<td align=’center’>
<a style=’border:none;’ href='”;
$email_part3=”‘ target=’_blank’><img src='”.get_bloginfo(‘home’).”/wp-content/themes/…/images/get_…ed.jpg’ alt=” border=’0’/>
</td>
</tr><tr>
<td align=’center’>
<p><font face=’Times New Roman, Georgia, serif’ size=’4′>You can view your … e-card by clicking \”Get …ed!\” or by <a style=’border:none;’ href='”;
$email_part4 =”‘ target=’_blank’>clicking here.</font></p>
<p><font face=’Times New Roman, Georgia, serif’ size=’4′>Check us out at ….com.</font></p>
</td>
</tr>
</table>
</td>
</tr>
</table>
<table width=’600′ cellspacing=’0′ cellpadding=’10’ border=’0′ align=’center’ style=’border:10px solid #FFFFFF;background:#FFFFFF;margin-bottom:50px;’>
<tr><td align=’center’>
<p><font face=’Times New Roman, Georgia, serif’ size=’2′>If you prefer that people not send you … e-cards, please click here</font></p>
</td></tr></table>
</td>
</tr>
</table>
</div>
</body>
</html> “;
add_filter( ‘wp_mail_content_type’, ‘set_html_content_type’ );
remove_filter( ‘wp_mail_from’, ‘wpse_new_mail_from’ );
remove_filter(‘wp_mail_from_name’, ‘wpse_new_mail_from_name’);
// lets start our custom link with the hashed id
$ecardlink = get_bloginfo(‘home’).”/receive?card=”.$hashfield;
// we’ll start with recpient 1 but override this later if we need to (i.e. if more than one card is sent)
$recipientvar = ‘&recipient=1’;
// and finally we have our final link (we’ll overwrite this for each user
$ecardlinkfinal = $ecardlink.$recipientvar;
$message = $email_part1.$user_email.$email_part2.$ecardlinkfinal.$email_part3.$ecardlinkfinal.$email_part4;
wp_mail($recipient1, $subject , $message, $headers);
if ($recipient2) {
$recipientvar = ‘&recipient=2’;
$ecardlinkfinal = $ecardlink.$recipientvar;
$message = $email_part1.$user_email.$email_part2.$ecardlinkfinal.$email_part3.$ecardlinkfinal.$email_part4;
wp_mail($recipient2, $subject , $message, $headers);
}
if ($recipient3) {
$recipientvar = ‘&recipient=3’;
$ecardlinkfinal = $ecardlink.$recipientvar;
$message = $email_part1.$user_email.$email_part2.$ecardlinkfinal.$email_part3.$ecardlinkfinal.$email_part4;
wp_mail($recipient3, $subject , $message, $headers);
}
if ($recipient4) {
$recipientvar = ‘&recipient=4’;
$ecardlinkfinal = $ecardlink.$recipientvar;
$message = $email_part1.$user_email.$email_part2.$ecardlinkfinal.$email_part3.$ecardlinkfinal.$email_part4;
wp_mail($recipient4, $subject , $message, $headers);
}
if ($recipient5) {
$recipientvar = ‘&recipient=5’;
$ecardlinkfinal = $ecardlink.$recipientvar;
$message = $email_part1.$user_email.$email_part2.$ecardlinkfinal.$email_part3.$ecardlinkfinal.$email_part4;
wp_mail($recipient5, $subject, $message, $headers);
}
remove_filter( ‘wp_mail_content_type’, ‘set_html_content_type’ );
add_filter( ‘wp_mail_from’, ‘wpse_new_mail_from’ );
add_filter(‘wp_mail_from_name’, ‘wpse_new_mail_from_name’);
return(true);
}
}