Create custom email and send it to Email Queue

Hello there

We are using SugarCRM 6.5 CE and let me share a new functionality I am trying to add to my sugarcrm configuration. I am creating a new button that launches a process which reads a custom "status field" of all accounts, and for all those which has the field set to "1" I create an email using the PHP Mailer funcion and send it to the mail address of the account.

The problem is that we are using a normal mail account (SMTP Configuration), and when we run the process, and as it affects too many accounts, the mails starts failing after the first 50 mails sent. Process runs fine, but the action to send more than 50 mails in the same process crashes.

I think it is due to the limitation of the mail account we have in the "General Configuration" in the Administrator Screen. However the configuration we have to send email Campaigns works fine as we can limit the number of mails per minute to be sent.

My question would be, Is there any way I could add the mail I am creating to the "Email Queue" of the emails that is produced when a Campaign is launched??

If so, could you please provide me an example of the code?

Thanks a lot!