views:

243

answers:

3

How to enable persistent SMTP connections in PHPMailer?

I will send many emails, so with persistent connections probably I will get performance gain.

+1  A: 

What do you mean by persistent SMTP connection?

First if you send a Email you are connected to the Server until it finishes the job. Secondly if you wanna send many emails (Probably your server will be in the blacklist), you write a loop in your PHP code, whitch fetches all Email adresses and passes them to the phpmailer and finaly sendts them. Thats how i would send mass mails.

streetparade
But I need to enable this in some place in PHPMailer, because it can connect and disconnect on every email sent
Paulocoghi
Ok, ok. I understand.
Paulocoghi
My server is recognized and has (almost) the necessary stuff to don't be blacklisted.We send emails regularly and have a large customer base, and this regularity also allows us to be well ranked in receive servers.
Paulocoghi
You should probably set up a queue and use the loop to process a batch at a time so that you can throttle the amount of emails
Cez
+1  A: 

By optimising the sending of emails, you might open yourself up as being identified as spamming and so cause web servers to block your IP.

How many emails are you sending? It may be better to actually throttle emails sent rather than speed up.

Jon Winstanley
Currently I'm sending 2500 emails.
Paulocoghi
Yes, I agree about throttling. Limiting to 500-1000 per hour should avoid any possibility of being seen as spamming
Cez
A: 

Hi.

I also need "persistent SMTP connection"

This is an explanation of what I want:

Our company uses a project management application which send email notifications every time a some action is taken (like new ticket created, feedback posted, file uploads, etc)

Now, we use Gmail.com's SMTP server as outgoing email server but because of slow uplink, our apps gets blocked. Blocking is time to connect to SMTP server (which is Gmail in this case)

Here I guess something like persistent-mysql connection will work for us. The idea is to connect to a SMTP-server and keep connection "open" all the time.

I am also impressed with the idea of queuing but I guess as we are using Gmail.com as our STMP server, this won't be any useful.

Any help, suggestions, guidance will be appreciated.

Thanks in advance.

-Rahul

rahul286