Solved

phpmailer

Posted on 2010-09-16
6
1,421 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 18

Expert Comment

by:Mark Gilbert
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:
Mark Gilbert 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
Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

 

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:Mark Gilbert
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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Marketers need statistics and metrics like everybody else needs oxygen. In this article we explain how to enable marketing campaign statistics for Microsoft Exchange mail.
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
In this video we show how to create an Accepted Domain in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: First we need to log into the Exchange Admin Center. Navigate to the Mail Flow >> Ac…
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.

623 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