Questions and discussion about developing processes and programming in PHP, JavaScript, web services & REST API.
Forum rules: Please search to see if a question has already asked before creating a new topic. Please don't post the same question in multiple forums.
By sgkalluri
#795279
Hello everyone,

I have a process wherein I have a list of alerts, could be 100 alerts or more, that need to be sent out as emails to respective recipients. This is to be achieved through a trigger.

The issue that I am facing is that I am unable to send more than 5 emails at a time. I am now assuming that there is some sort of a hard limit on the number of emails that can be sent continuously within a session.

Is this the case? If so, can this limit be changed? What could be the procedure for that change?

Best wishes,
SGK
User avatar
By amosbatto
#795281
This is probably a limit from your email provider. Gmail, Yahoo! and Hotmail limit the number of emails you can send out in a day.

Are you sending these emails separately or are you limited to 5 recipients per email (i.e., only 5 addresses in the TO line)?
By sgkalluri
#795283
Thanks Amos.

There does not seem to be a restriction on recipients. I have a for loop, which loops, say, 50 times. I collect data in each of these loop iterations, and at the end of each loop iteration, I use the PMF email function to send out the email. So, the PMF email function is looped 50 times (as per this example) in one trigger execution.

Best wishes,
SGK
By sgkalluri
#795306
Thanks for sending the links.

I don't think there is a limit on the number of emails to be sent in every attempt from my email provider.

Anyway, I got over the issue in the following way...

a) Create a while loop in the trigger.
b) Placed the PMF email function within the while loop.
c) PMF email function executes in the while loop, with a unique hidden code in the message body.
d) Then I check the app_message table for APP_UID and APP_MSG_BODY for that record that has the hidden unique code in the message body.
e) If I find the record, and the APP_MSG_STATUS field is 'Pending', then I delete that record from app_message table.
f) The while loop repeats 5 times (just to limit the # of executions of the loop). If the APP_MSG_STATUS field is 'Sent', then I exit this loop.

g) I maintain a grid variable with unique information of the emails I need to send.
h) I then have a dummy screen. This screen would just show the user which email is being processed.
i) Once the user initiates the emails to be sent from the original screen, then the next screen that appears is the dummy screen.
j) I have a trigger which executes before the dummy screen appears. This trigger identifies the email record to be executed, executes steps a) to f) above, then marks this email record as sent.
k) The dummy screen now appears, with information displayed to the user that so and so email has been sent.
l) However, the dummy screen immediately submits on display (done via javascript), so that the user has no chance of interacting with the dummy screen.
m) Depending on number of email records remaining to be processed, I use the redirect step function to redirect to either the original screen or back to the dummy screen (in which case the next email record is executed).

This takes more time, however, it is steady with no errors.

Best wishes,
SGK
User avatar
By amosbatto
#795308
If an exception occurs in your while loop, that would prevent PMFSendMessage() from being executed 50 times. When you use the PM debugger, do you see any error message in the @@__ERROR__ variable?

Set a counter in your while loop and see how many times it executes:
Code: Select all
@%count = 0;
while ($i < 50) {
   PMFSendMessage(...); 
   @%count++;
}

Hello. For rental housing, there are software solu[…]

Experience heightened pleasure with Cenforce 100 M[…]

Get an instant solution to move emails to MBOX for[…]

Most Demanding OST to PST Converter

The most demanding OST to PST Converter is TrijaT[…]