We help IT Professionals succeed at work.

phpmailer

1,573 Views
Last Modified: 2013-12-17
Hi,
I am using PHPmailer to send emails from my server.
I have two questions:

1. I notices that when I send Emil, I doesn't get back till it sends it.
   Is there a way that I can send it asynchronous (so I don't need to wait).?
   If not, is there a 'php queue' that I can send 'tasks' to be executed asynchronous .

2. I will use it for many users. Is there a problem with it? or do I need to create a special queue for it?
Comment
Watch Question

Mark GilbertSenior Performance Engineer

Commented:
As you say you are dealing with a large number of messages I would setup a dedicated SMTP server and have phpmailer direct all the mail to that server. That way the class should work alot faster as it's passing off the job rather than handling the whole delivery itself and then in the SMTP configuration you can then set it up to process outbound mail in batches. Perhaps set it to send every 5 minutes.

That's the best recommendation I can make. Other than that you may be able to also route through to an external SMTP server.

Hope this helps.

Author

Commented:
Currently I cannot dedicate an external server (I start very small).
How do I configure the SMTP to process it out bound.
I don't want to send every xxx, I just want to send it asynchronous so I don't need to wait (in the process that called it).
Senior Performance Engineer
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION

Author

Commented:
The problem is not that it slow (now).
I just wanted to be prepared when there are many users.
The current configuration that I am testing it in my WAMP (simulation for Appachi in Windows) and defined the SMPT server as my server which is located in another location.
There was a problem with the communication and I noticed that my task was hanged till the communication was back again. But now I think that it will not happen in a real network.
Mark GilbertSenior Performance Engineer

Commented:
Thanks for accepting my answer. I'm glad I was able to help.

As a sidenote and follow up to your latest comment, don't assume that you won't have network issues at a later stage. For this reason it's probably a good idea to perhaps queue the messages in a database table and have a separate php process to go through those records and send out the emails. By separating the retrieval from a customer, with actually sending an email with that content you are ensuring that their process isn't hindered by any possible delays that the script may have contacting the smtp server, php mail functions, etc. Then if there are any delays you could have an alert sent to you stating that there's a problem with the mail queue which you could then intercept and redirect to another server if need be.

Hope this helps.

Author

Commented:
Thanks.
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.