I can't figure out for the life of me why this is sending twice. It's not in any loop, and I have an if statement checking if isset but nothing I do stops it from sending twice.
It's a basic form that has 4 fields but data is extracted based on one field and email sent out based on the email field.
Everytime I submit the page it sends it twice.
//Email Function
if(isset($_GET['email'])){
if($_GET['employee'] == '1') {
$pp = 'Plan Participant (Employee)';
} else if($_GET['employee'] == '2') {
$pp = 'Plan Participant (Employer)';
}
//$headers = 'From: americasbest401k.com' . "\r\n";
$company = '<br><br>Company Name: ' . $co_name ;
$plan = '<br><br>Plan Name: ' . $plan_name;
$headers = 'From: Fee Checker Page <Americasbest401k.com>' . "\r\n";
$message = $_GET['name_field'] . ' used the fee checker<br><br>Email: ' . $_GET['email'] . '<br><br>Participant or Sponsor: ' . $pp . '' . $company . ' ' . $plan;
wp_mail('support@americasbest401k.com', '401k Fee Checker', $message, $headers);
//email to user
$headers = 'From: '.get_post_meta($post->ID,'from-email',true). "\r\n";
$message = wpautop( get_post_meta($post->ID,'employer-email',true)).' <a href="'. site_url().'/fee-checker/?reffered=yes&company='. $_GET['company'].'"><strong>'.get_post_meta($post->ID,'fee-link-text',true).'</strong></a>';
wp_mail($_GET['email'], "Take Action on Your 401k!", $message, $headers);
}
$testemail = 1;
and tag it on the end of the subject line:"Take Action on Your 401k! " . $testemail
then increment it by 1 after thewp_mail
function:$testemail++;
If the email subject lines have 1,2 after them then the code is being called multiple times. – Jason Murray Mar 1 '15 at 19:56mail()
function what happens? – skribe Mar 1 '15 at 20:31