Solved

phpmailer

Posted on 2010-09-16
6
1,389 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?
0
Comment
Question by:VapiSoft
  • 3
  • 3
6 Comments
 
LVL 18

Expert Comment

by:ingwa
ID: 33691983
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
 

Author Comment

by:VapiSoft
ID: 33692085
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
 
LVL 18

Accepted Solution

by:
ingwa earned 500 total points
ID: 33692305
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

Author Comment

by:VapiSoft
ID: 33692419
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
 
LVL 18

Expert Comment

by:ingwa
ID: 33692468
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
 

Author Comment

by:VapiSoft
ID: 33692507
Thanks.
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Resolve DNS query failed errors for Exchange
This article discusses four methods for overlaying images in a container on a web page
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now