Send different emails

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.
Post Reply
JAW
User
Posts: 98

Send different emails

Post by JAW »

Hello,
When a record is added or edited I would like to send different emails to different people. The content needs to be totally different and the recipient needs to be different. I am using Email_Sending and I have all the code in place. The problem is the second email that goes out includes the first one and I do not want that to happen. Is there a way to use Email_Sending to send two separate and distinct emails to two separate and distinct users? I need to prevent the first email from being included in the second one when it sends.

Any help will be greatly appreciated.

Regards,
JW


sangnandar
User
Posts: 980

Post by sangnandar »

Post your existing code.


joubertjg
User
Posts: 66

Post by joubertjg »

Use the

$email->send() ;

between the emails.

The last email you dont need to use the send() option.


JAW
User
Posts: 98

Post by JAW »

Thank you all for your replies, and I apologize for not responding sooner. So this is what I am attempting to do.

I have two people who need to get an email on add. One is the Consultant and one is the Sales Rep. The subject and content are different for each. Something very similar to the following.

Send email to the consultant.
$Email->Recipient = "consultant@domain.com";
$Email->Subject = "Schedule Change Request Submitted";
$Email->Content .= "A change request has been submitted.";
$Email->Content .= "<br><BR>Reason for the reguest " . $Args["rsnew"]["Reason"] . "";

Send email to the sales rep.
$Email->Recipient = "salesrep@domain.com";
$Email->Subject = "Your Schedule Change Request";
$Email->Content .= "This is the change you requested.";
$Email->Content .= "<br><BR>Reason for the reguest " . $Args["rsnew"]["Reason"] . "";

So the first one goes out no problem and the consultant receives the request. The problem is the second one goes out but includes the content for first one. I want them to be totally independent of one another so one does not know what the other one is receiving. I thought I could use row_inserting or row_inserted to send one and email_sending to send the other but I could not figure out how to send an email in row_inserting/row_inserted. If anyone has any suggestions on either method it would be greatly appreciated.

Regards,
JW


arbei
User
Posts: 9384

Post by arbei »

JAW wrote:
$Email->Content .= "A change request has been submitted.";

That is because you use ".=" which is concatenating assignment operator, read https://php.net/manual/en/language.operators.string.php.


mobhar
User
Posts: 11726

Post by mobhar »

Your code should be like as follows:

Send email to the consultant.
$Email->Recipient = "consultant@domain.com";
$Email->Subject = "Schedule Change Request Submitted";
$Email->Content = "A change request has been submitted.";
$Email->Content .= "<br><BR>Reason for the reguest " . $Args["rsnew"]["Reason"] . "";

Send email to the sales rep.
$Email->Recipient = "salesrep@domain.com";
$Email->Subject = "Your Schedule Change Request";
$Email->Content = "This is the change you requested.";
$Email->Content .= "<br><BR>Reason for the reguest " . $Args["rsnew"]["Reason"] . "";


Post Reply