Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1434
  • Last Modified:

phpmailer

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?
0
VapiSoft
Asked:
VapiSoft
  • 3
  • 3
1 Solution
 
Mark GilbertSenior Performance EngineerCommented:
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.
0
 
VapiSoftAuthor 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).
0
 
Mark GilbertSenior Performance EngineerCommented:
As it's slow, leads me to believe that there's a problem somewhere. Are you on a shared host? If so the default php mail function which phpmailer uses if no smtp is defined may be bogged down or overloaded. If the mail function has been routed to an smtp server on the host then that smtp may also be bogged down or may have something setup which is causing you latency. If it's a machine you have complete control over, is it possible that you are on a busy network? Mail shouldn't take long at all however if your process ntains many checks or functions then that may also be the cause of the slowdown. Without seeing your code specifically I am unable to determine the root cause.

If you did route your mail to an smtp server to batch process, you are alleviating the php processes to simply hand off the mail for processing via the smtp rather than have php do all the hard work to make sure it's sent before refreshing the page.

Another alternative would be to save the results of what you want to send via email to a database and have a separate process to go through those records and email them.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
VapiSoftAuthor 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.
0
 
Mark GilbertSenior Performance EngineerCommented:
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.
0
 
VapiSoftAuthor Commented:
Thanks.
0

Featured Post

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now