One solution I could find for your scenario will be
->Store all the send email addresses to one array and the Non send items to another array.
->And the finally update the table with theses two arrays in two update queries
Further explanation of Solution
-> Send mail
-> Check mail send status
-> If mail send status is Success add the user record id to array mail_success
-> If mail send status is Fail add the user record id to array mail_fail
-> After all mail have been send to all users, Update the table with the user record id, mail status and send date and time
Considering the size of the mailing list it will be optimum to update table after all the mail have been send.
Hi,
Thanks for the input, currently what I have done is, running a cron job every 5 minute which will send mails in the batch of 250 and in the end I am updating all those 250 records using a single IN query. I think that did the job but now I have not much idea about the failed status thing.
I am currently using batchsend to send out mails, I am not sure how I will get the failed emails? (Also by failed you meant, bounced back or something? - any specific error code?)
When you execute mail function, If the mail is sent correctly, the mail function will return a value '1' and if the mail was not sent it will return a value '0'. It has nothing to do with the email id being correct, if the parameters are passed correctly for the mail function and if SMTP is set correctly it will return 1. So if it returns '0' for a mail id, then it can be stored to send_fail array and can be resent later.
But the only problem here is, i have batchsend running and it is running out of the loop, so I am not sure how it will throw the status for each mail separately..