This topic is locked
[SOLVED]

  mail is sent twice

5/19/2011 3:24:07 AM
PHPRunner General questions
S
shoppy author

Hi,
I added an event that sends an email every time I edit a record.

That part works fine.

The only problem is that the email is being sent twice.
Can anyone help me please?



// After record updated

function AfterEdit(&$values, $where, &$oldvalues, &$keys,$inline)

{

// ********** Send conformation email ************
ini_set('SMTP','smtp.xxxxxx.nl');

$html = true;

// variables

$to = $values["email"];

$from = "info@xxxxxxx.nl";
$subject = "Voortgang schade van ".$values["Schadedatum"];
$message = $values["Commentaar"] . "<br />" . "<br />" . "<br />" . "<br />";

$message .= 'Met vriendelijke groet,' . "<br />";

$message .= 'Administratie';
//Headers

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

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

$headers .= 'X-Mailer: PHP/' . phpversion() . "\r\n";

$headers .= 'X-Priority: Normal' . "\r\n";

$headers .= ($html) ? 'MIME-Version: 1.0' . "\r\n" : '';

$headers .= ($html) ? 'Content-type: text/html; charset=iso-8859-1' . "\r\n" : '';


// Send the message

mail($to, $subject, $message, $headers);
header("Location:Part__schades_list.php?a=return");

exit();
} // function AfterEdit
/ After record added

function AfterAdd(&$values,&$keys,$inline)

{

// Parameters:

// $values - Array object.

// Each field on the Add form is represented as a 'Field name'-'Field value' pair

// $keys - Array object with added record key column values
//********** Redirect to another page ************

header("Location:Part__schades_list.php?a=return");

exit();
} // function AfterAdd
?>
S
shoppy author 5/19/2011

Solved!
I changed some things in the $headers and problem was solved.

Just compare the two codes if you want to learn what has been changed.



function AfterEdit(&$values, $where, &$oldvalues, &$keys,$inline)

{

// ********** Send conformation email ************
ini_set('SMTP','smtp.xxxxx.nl');

$html = true;
// variables

$to = $values["email"];

$from = "info@xxxx.nl";

$website_naam = 'MY BIZZ NAME';



$subject = "Voortgang schade ".$values["Schadenummer"];
$message = $values["Commentaar"] . "<br />" . "<br />" . "<br />" . "<br />";

$message .= 'Uw Online Dossier: http://www.winkel-advies.nl/winkel-advies/'; . "<br />" . "<br />";

$message .= 'Met vriendelijke groet,' . "<br />";

$message .= 'Administratie';
//Headers

$headers = 'From: ' . $website_naam . ' <' . $from . '>' . PHP_EOL;

$headers .= 'X-Mailer: PHP/' . phpversion() . PHP_EOL;

$headers .= 'X-Priority: Normal' . PHP_EOL;

$headers .= ($html) ? 'MIME-Version: 1.0' . PHP_EOL : '';

$headers .= ($html) ? 'Content-type: text/html; charset=iso-8859-1' . PHP_EOL : '';


// Send the message

mail($to, $subject, $message, $headers);
header("Location:Part__schades_list.php?a=return");

exit();
} // function AfterEdit
// After record added

function AfterAdd(&$values,&$keys,$inline)

{

// Parameters:

// $values - Array object.

// Each field on the Add form is represented as a 'Field name'-'Field value' pair

// $keys - Array object with added record key column values
//********** Redirect to another page ************

header("Location:Part__schades_list.php?a=return");

exit();
} // function AfterAdd
?>