This topic is locked

Mail selected users

1/27/2021 11:15:13 AM
PHPRunner General questions
D
dirk author

Hello,

The example "Send an eamil to selcted users" in the manual does not work.

see the php list below



$emails = array();
while( $data = $button->getNextSelectedRecord() )

{

if( $data["Email"] )

$emails[] = $data["Email"];

}
// send the email

$email = implode(", ", $emails);

$subject = "testing";

$body = "test";

$arr = runner_mail(array('to' => $email, 'subject' => $subject, 'body' => $body));
$result["txt"] = "Emails were sent.";
// if error happened print a message on the web page

if( !$arr["mailed"] )

{

$errmsg = "Error happened:
";

$errmsg.= "File: " . $arr["errors"][0]["file"] . "
";

$errmsg.= "Line: " . $arr["errors"][0]["line"] . "
";

$errmsg.= "Description: " . $arr["errors"][0]["description"] . "
";

$result["txt"] = $errmsg;

}



controle syntax => OKE

Designation of 2 users
Get the following error.
Array{"txt":"Error happened:

File:

Line:

Description:

"}
Is there anyone who can say what's wrong?
thanks

D
DealerModulesDevClub member 1/27/2021



Hello,

The example "Send an eamil to selcted users" in the manual does not work.

see the php list below
controle syntax => OKE

Designation of 2 users
Get the following error.
Array{"txt":"Error happened:

File:

Line:

Description:

"}
Is there anyone who can say what's wrong?
thanks


Hi Dirk,

I was having a similar problem and got some help from Fernando.

The code is at this post, maybe you can use it as an example for your project.
https://asprunner.com/forums/topic/27915-need-some-direction-on-sending-email-to-multiple-records-selected-in-a-list/pagep93050&#entry93050
Paul

D
dirk author 1/28/2021



Hi Dirk,

I was having a similar problem and got some help from Fernando.

The code is at this post, maybe you can use it as an example for your project.
https://asprunner.com/forums/topic/27915-need-some-direction-on-sending-email-to-multiple-records-selected-in-a-list/pagep93050&#entry93050
Paul




Sorry Paul,

But this presents the same problem.

D
dirk author 1/28/2021

The code below no longer gives an error, but also does not send an email.



while( $data = $button->getNextSelectedRecord() )

{

// Send only if email field not empty

if( $data['email'] ) {

// This no longer should be an array of emails

$result['email'] = $data["email"];

$email = $result['email'];

$body = "test";

$subject = "test";

// Email will be sent for each record

$arr = runner_mail(array('to' => $email, 'subject' => $subject, 'body' => $body));

$result["txt"] = "Email verzonden naar ".$email;

}

}



The email settings are set in the misc
Can someone tell me why no mail is being sent
thanks

S
smez 1/28/2021



The code below no longer gives an error, but also does not send an email.
The email settings are set in the misc
Can someone tell me why no mail is being sent
thanks


Try:

runner_mail(array('to' => $email, 'subject' => $subject, 'body' => $body));
instead of:

$arr = runner_mail(array('to' => $email, 'subject' => $subject, 'body' => $body));

Sergey Kornilov admin 1/28/2021

The code in the manual does work.
As a first step, you need to make sure that email settings are correct. For this purpose send a simple test email to a hardcoded email address from one of the events or from the button. Once you get a simple email working you can proceed to more complicated examples. One thing at the time.