Page 1 of 1

send email to many people

Posted: Mon Nov 13, 2017 3:49 pm
by Dalila

Hi,
i used this code to send email to many people when a table is added.
The email arrives correctly but in the email box i saw that every account email customers are visible in the "to" field. Is it possible that the email arrives to my selected customers but each customer see only his name in the "to" field?

I post the code

/ Email Sending event
function Email_Sending(&$Email, &$Args) {

if (CurrentPageID() == "add") { // Means email sending by insert record.
$rsnew = $Args["rsnew"]; // get the $rsnew from the $Args array.
ew_Execute("SELECT email FROM utenti WHERE livello = 1", function($row) use (&$Email) {
if ($row["email"]) $Email->Recipient = $Email->Recipient . " , " . $row["email"];
});
}
return TRUE;

}

thank you so mutch


Re: send email to many peolple

Posted: Mon Nov 13, 2017 6:08 pm
by mobhar

Dalila wrote:
Is it possible that the email arrives to my selected customers but each customer
see only his name in the "to" field?

No. For such case, then do not use "Email_Sending" server event. You need to use "ew_SendEmail" function (see this function from the generated "phpfn*.php" file).

Just make a loop to read/get all your recipient email using "Row_Inserted" server event, and inside that loop, just call that "ew_SendEmail" function to send email one-by-one to the specified email recipient.


Re: send email to many people

Posted: Tue Nov 14, 2017 9:41 pm
by Dalila

I do not deserve it because I did not write it.
I can try by myself, like de code above...

/ Email Sending event
function ew_SendEmail(&$Email, &$Args) {

if (CurrentPageID() == "add") {
$rsnew = $Args["rsnew"];

foreach($rsnew as $Email)
ew_Execute("SELECT email FROM utenti WHERE livello = 1", function($row) use (&$Email) {
if ($row["email"]) $Email->Recipient = $Email->Recipient . " , " . $row["email"];
});
}
return TRUE;

}

Tahnk you for help me.


Re: send email to many people

Posted: Tue Nov 14, 2017 9:56 pm
by mobhar

ew_SendEmail is a built-in function and generated by PHPMaker. In other words, you don't need to create it again. You just need to call that function by supplying the parameter from you. For more info how to learn the function, see the code of ew_SendEmail from the generated "phpfn*.php" file.


Re: send email to many people

Posted: Fri Nov 17, 2017 3:59 pm
by Dalila

thank's I try