This topic is locked

BeforeAdd

12/28/2006 11:11:40 AM
PHPRunner General questions
L
lawfour author

I thought this code worked but it stops at CC: can someone tell me why?
function BeforeAdd(&$values)

{
// Parameters:

// $values - Array object.

// Each field on the Add form represented as 'Field name'-'Field value' pair
//** Send email with new data ****
$email=$values["Email"];

$message="Airgas Only: http://www.kccesr.org/gpage.html";

$subject="KCC Gas Order";

$headers = "From: larry@kccesr.org" . "\r\n\n" ."CC: gasorders@lawfour.com";
foreach($values as $field=>$value)

$message.= $field." : ".$value."\r\n\n";
mail($email, $subject, $message, $headers);
return true;
// return true if you like to proceed with adding new record

// return false in other case
}

Sergey Kornilov admin 12/28/2006

Here is the correct way to set additional headers:

// Additional headers

$headers .= 'To: Mary <mary@example.com>, Kelly <kelly@example.com>' . "\r\n";

$headers .= 'From: Birthday Reminder <birthday@example.com>' . "\r\n";

$headers .= 'Cc: birthdayarchive@example.com' . "\r\n";

$headers .= 'Bcc: birthdaycheck@example.com' . "\r\n";


I guess you have extra \n in your code and CC should be spelled as Cc.

L
lawfour author 12/28/2006

Hi
Could not get the Cc: to work, Now i am trying to do it another way. Basically what I want to do is send 2 emails from one record, both emails are set in a email fields Email & Email2
The code below only sends one email, field [Email] the other field [Email2] seems to be ignored. I tried various arrangements using the headers code but I got the same result only on email is sent instead of two.
This is the only problem I have once this is figured out I am finished with this project. So I hope someone can help.
Thanks

Larry
function BeforeAdd(&$values)

{
// Parameters:

// $values - Array object.

// Each field on the Add form represented as 'Field name'-'Field value' pair
//** Send email with new data ****
$email=$values["Email" . "Email2"];

$message="Airgas Only: http://www.kccesr.org/gpage.html";

$subject="KCC Gas Order";
// Additional headers

$headers = 'From: ESR Website <larry@kccesr.org>' . "\r\n";
foreach($values as $field=>$value)

$message.= $field." : ".$value."\r\n\n";
mail($email, $subject, $message, $headers);
return true;
// return true if you like to proceed with adding new record

// return false in other case
}

J
Jane 12/29/2006

Larry,
here is the correct event code:

function BeforeAdd(&$values)

{

// Parameters:

// $values - Array object.

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

//** Send email with new data ****

$email=$values["Email"]." ,".$values["Email2"];

$message="Airgas Only: http://www.kccesr.org/gpage.html";

$subject="KCC Gas Order";
// Additional headers

$headers = 'From: ESR Website <larry@kccesr.org>' . "\r\n";
foreach($values as $field=>$value)

$message.= $field." : ".$value."\r\n\n";

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

// return true if you like to proceed with adding new record

// return false in other case

}