This topic is locked
[SOLVED]

 email send twice, why

10/18/2013 11:31:15 AM
PHPRunner General questions
S
shoppy author

Hello all,
In an event I have this code:



ini_set('SMTP','smtp.blahblah.com');

global $conn;
//$str = "select * from _payments where ".$where;
$str = "SELECT

`_payments`.PaymentID,

`_payments`.Paymentstatus,

`_payments`.Paymentdatum,

`_payments`.Paymentherinnering,

`_leden`.LedenID,

`_leden`.naam,

`_leden`.forumnaam,

`_leden`.email,

`_leden`.lidnr

FROM `_payments`

INNER JOIN `_leden` ON `_payments`.LedenID = `_leden`.LedenID

WHERE _payments." . $where;
$rs = db_query($str,$conn);

$data = db_fetch_array($rs);
//************************variabelen*********************************************

$to = $data["email"];

$from = "info@blahblah.com";
// To send HTML mail, the Content-type header must be set

$headers = "To: $to" . "\r\n";

$headers.= "From: $from" . "\r\n";

$headers.= "MIME-Version: 1.0" . "\r\n";

$headers.= "Content-Type: text/html; charset=\"iso-8859-1" . "\r\n";
//*********************stuur bevestiging wanneer een nieuw lid is aangemeld****************

if ($values["status"] == "WELKOM")

{

$stremail = "select * from _emails where email='WELKOM'";

$rsemail = db_query($stremail,$conn);

$dataemail = db_fetch_array($rsemail);



$email=$data["email"];

$message="";

$subject=$dataemail["email_subject"];



$message = $dataemail["email_body"];

$message = str_replace("%%forumnaam%%",$data["forumnaam"],$message);



$message = str_replace("%%lidnr%%",$data["lidnr"],$message);

$message = str_replace("%%lidnr%%",$_REQUEST["editid1"],$message);



mail($email, $subject, $message, $headers);

}
//*********************stuur bevestiging wanneer een lidmaatschap afloopt****************

if ($values["status"] == "LOOPT AF")

{

$stremail = "select * from _emails where email='LOOPT AF'";

$rsemail = db_query($stremail,$conn);

$dataemail = db_fetch_array($rsemail);



$email=$data["email"];

$message="";

$subject=$dataemail["email_subject"];



$message = $dataemail["email_body"];

$message = str_replace("%%forumnaam%%",$data["forumnaam"],$message);

$message = str_replace("%%betaaldatum%%",$data["Paymentdatum"],$message);

$message = str_replace("%%herinnerdatum%%",$data["Paymentherinnering"],$message);

$message = str_replace("%%lidnr%%",$data["lidnr"],$message);

$message = str_replace("%%lidnr%%",$_REQUEST["editid1"],$message);
mail($email, $subject, $message, $headers);

}
//*********************stuur bevestiging wanneer een lidmaatschap is verlengd****************

if ($values["status"] == "VERLENGD")

{

$stremail = "select * from _emails where email='VERLENGD'";

$rsemail = db_query($stremail,$conn);

$dataemail = db_fetch_array($rsemail);



$email=$data["email"];

$message="";

$subject=$dataemail["email_subject"];



$message = $dataemail["email_body"];

$message = str_replace("%%forumnaam%%",$data["forumnaam"],$message);

$message = str_replace("%%betaaldatum%%",$data["Paymentdatum"],$message);

$message = str_replace("%%herinnerdatum%%",$data["Paymentherinnering"],$message);

$message = str_replace("%%lidnr%%",$data["lidnr"],$message);

$message = str_replace("%%lidnr%%",$_REQUEST["editid1"],$message);
mail($email, $subject, $message, $headers);

}
//*********************stuur bevestiging wanneer een lidmaatschap is verlengd****************

if ($values["status"] == "BETAALD")

{

$stremail = "select * from _emails where email='BETAALD'";

$rsemail = db_query($stremail,$conn);

$dataemail = db_fetch_array($rsemail);



$email=$data["email"];

$message="";

$subject=$dataemail["email_subject"];



$message = $dataemail["email_body"];

$message = str_replace("%%forumnaam%%",$data["forumnaam"],$message);

$message = str_replace("%%betaaldatum%%",$data["Paymentdatum"],$message);

$message = str_replace("%%herinnerdatum%%",$data["Paymentherinnering"],$message);

$message = str_replace("%%lidnr%%",$data["lidnr"],$message);

$message = str_replace("%%lidnr%%",$_REQUEST["editid1"],$message);
mail($email, $subject, $message, $headers);

}
return true;


So when a change the status of a member in one of the options from the event (WELKOM or another) the email is send twice to the member.

Can anyone tell me why that is please?
John

Sergey Kornilov admin 10/18/2013

Try to remove the following line:

$headers = "To: $to" . "\r\n";
S
shoppy author 10/18/2013



Try to remove the following line:

$headers = "To: $to" . "\r\n";



Sorry Sergey but if I remove that line it doesn't send the email anymore.
Sorry, it does!!!
Problem solved, THANKS

Sergey Kornilov admin 10/18/2013

Not sure what else I can do just looking at this code.
I see that you specified TO email address twice and assumed that might be the reason.