Reduce mail sending time - php

I am sending bulk mail using phplist third party component. But when I am sending above 1000 mail it's taking too much time to send that message. It's taking 4 to 5 hours to send all the mails completely.
Is it possible to reduce the mail sending time? How?

The easiest way is to configure a local smtp server, and have that relay to the "real" smtp server. It shouldn't be taking that long to complete, from code, the email sending. But the time of "actual" delivery is up to the nodes inbetween, and nothing to do with you.

As the previous poster said, configure a local queueing smtp server, if you have shell access to the server. Postfix is a good candidate, it's lightweight and easy to configure. Sending a thousand emails should not take more than a few seconds.
You could use the pear package Mail::Factory as well to specify a lot of options and use various methods of calling the MTA (Mail Transport Agent, i.e. Postfix).

Related

MTA for receiving mails, in PHP

is there a library/class/code-snippet/etc. that allows me to directly receive mail in php?
So that I don't have to run an additional sever in an other process and then have to somehow send the mails to the already-running php-process.
I've been looking around for a while, but results for "php" and "mail" or "mta"/"smtp" on google focus mostly on sending mail, or retrieving it using pop3 or imap...
[EDIT]
What I'm trying to do is forward the messages to an IRC-channel, so obviously when the IRC-bot (in PHP) isn't running, loosing the mails is not a big deal. However having a low latency between receiving the mail and posting it on IRC is.
I've never seen a compete SMTP server in PHP and it doesn't surprise me. I don't think you want to go that route. I can think of two other ways to do this:
Use procmail (or similar) with your existing SMTP server and make a rule that forwards the messages to your PHP script. Pretty simple to do and it will fire the script the instant the message is received.
Have the messages delivered to some existing mailbox, then have your PHP script continually poll it (via POP or IMAP) for new messages. When you see a new message, pass it to IRC and delete it. How long it takes the message to appear depends on how often you poll the inbox.
Writing your own SMTP server to act as a MTA is a big undertaking. You could take a look at http://cloudmailin.com. CloudMailin allows you to receive the incoming email as an HTTP Post and acts as the MTA sending the email direct to your PHP app. The PHP app can then process the email and send it to the IRC channel.
The MTA (Mail Transport Agent) is an application (i.e. sendmail, exim) that is used to move mail from location to location. As far as I know, there is no MTA coded in PHP. PHP offers classes and scripting that will handle mail transport, but it still processes through an existing MTA.
You should be able to configure the MTA to pass mail through a given PHP script to accomplish what you are looking for.
Writing your own SMTP server is a huge undertaking. Do NOT go this route. You'll waste an incredible amount of time duplicating work that's been done already. Choose one of the 'big' SMTP servers (postfix, exim, sendmail, etc...) and go with that.
Don't think that just setting up a dinky little script to listen to port 25 will do the trick. SMTP servers are incredibly complicated beasts and the mechanics of setting up that port 25 socket likely occupy less than 0.00000000000000000000000000000000001% of the work. (this number is totally true, I asked my gut what it feels and that's what came out).
Try this: http://www.php.net/manual/en/refs.remote.mail.php
10 seconds of googling. SMTP is for mail relay, although it is the defacto protocol for mail clients to send mail, due to the Unix heritage of every box running an SMTP mail relay.
POP3 and IMAP provide mail clients' access to mail.

options for sending email via PHP

I am pretty new with the options of sending email via PHP code. The options available are sendmail, postfix, and PHPMail. If I use sendmail and postfix this means that I have to use PHP's mail function. I don't know about PHPMail. I will be sending email across domains (hotmail, yahoo, gmail, etc). It's an automatic email sent to a user's email after they completed something (say a registration). What do you guys think about this?
I've tried setting up sendmail in my Ubuntu server, but had some difficulties in setting it up. So that's why I am probably looking for more options.
You need a MTA (mail transport agent) on your machine (sendmail, postifx, ...) or you can connect to a mail provider like gmail using SMTP.
PHPMailer might be a good class for sending emails if you're not using any framework.
PHPMailer is on Google Code and GitHub.
You should have a pretty easy time setting up sendmail on ubuntu
http://ubuntuforums.org/showthread.php?t=196112
This gives the basics it takes to get sendmail installed.
If you are running this server from your house or some non-datacenter there is a chance that your ISP is blocking the port numbers you need such as port 25.
Read through that thread and it should give you some good suggestions for issues you may have.

Need Help in send news letter using PHP mail function

Need your help in over coming the following issues.
i need to send opt-in newsletters to the user. But using "gmail SMTP", i will not be able to send more than 400 mails per day.
Even if i use the mail option given in the shared server, i will not be able to send mails more than 300 mails per day.
Can you please suggest any other way i can handle this issue. Is it possible to use PHP mail functions? are there any limitations in sending the number of mails to the users.
can a server control the mails sent using PHP mail function.
Thanks for reading.
thanks a lot
The limitation on the number of mails you can send per day/hour is set by your SMTP server. In case of the mail() function, it is once again set by your host. If you wish to remove this limitation, generally you would:
Talk to your host's tech support and
ask them to raise the limit. Some
hosts like Fatcow raise your limit
from 500 to about 5000 (don't remember the exact numbers).
You can buy a dedicated virtual
server with no such restriction,
where the limit would only be the
speed at which you could send your
emails.
You can try newsletter mailing
software/add-ons like
ConstantContact that help you manage
your newsletters effectively.
1- you can buy vps and send many mail
2- you can buy smtp server for many sent
3- you can buy valid ip and set in your pc ... run somethings like postfix and sent mail in this way ...
Use an smtp relay service. I've had good experiences with smtp.com in the past (I'm not affiliated with them in any way). You can grab a library to connect to it and get going relatively fast.
Yuou should check this link http://www.emailaddressmanager.com/tips/server-smtp-limit.html
Every server comes with its own smtp/mail limit, usually 300-500 for shared and between 500 and 2k for dedicated. This is by ICAN regulations i believe to control spam as much as possible.
Most of the dedicated servers out there will increase your mail/smtp relay limit on a request mentioning why you need to increase,etc. You will also need to include an unsubscribe link in the newsletter so that users who recieve the mail can opt out from future mails.
Increasing the mail limit is sequential usually and it can be upto 100,000 on a godaddy dedicated server from what i got from chat support #go daddy.
As for gmail smtps, you can't send more than 500 a day and 2000 for business/educational google apps account.

Is there a SMTP mail transfer library in PHP

I want to write an email transfer service and need a MTU replacement of sendmail/postfix.
I'm not looking how to deliver to a transmitting SMTP server (like a postfix listing on a SMTP port). I also don't need the receiving part of the server, bounces etc. would go to a different existing postfix.
All of it in pure PHP. SMTP is a pretty easy protocol but this would require access to the MX DNS record and other lot of details that need to be taken care of.
Why do i need this? Because most shared internet providers have insane low limits for sending out emails like 500 per day. Thats almost nothing if you want to setup even the lowest traffic email list.
EDIT: Please Note: The code needs to connect to the receivers SMTP server and deliver the message with an adapted header set (removed BCC list, added Path route). If you see a SMTP class less then 5000 lines or requires you to configure a SMTP hostip and port then this is not the stuff i'm looking for.
It needs to do all the stuff sendmail is doing just as a PHP library.
I use Pear's Mail class.
EDIT
After re-reading this, I see there's more to it than just a library. You are asking to send direct to the remote MX.
Why reinvent the wheel? Set up an instance of postfix on the server, which only listens to connections from the web server... and let an MTA do what it does best. Hand off the messages from php to a real mail server and move on.
In the case of ISP's that block outbound port 25 and force the use of a smarthost, this also allows you to restrict the rate of messages sent to the smarthost.
Lastly, sending straight to the end MX from your php script is a bad idea, because if you send to me, I'll never get it. I and many other sites use "greylisting" to reduce spam, which denies all initial requests with a 450 temporary error. Real MTA's will try again, but unless you implemented a delay queue and try again, your message will never go through.
We use http://sourceforge.net/projects/phpmailer/ to do SMTP email from PHP
SwiftMailer is the only library you'll need.
Try Zend Framework component Zend_Mail (you can use the component independently of the entire framework).
Here is something I wrote. It's quite minimal and I don't know how well it performs, but I wrote it with the intention of replacing sendmail, meaning that it will take a message, lookup all the MX records for the recipient domains, contact those mail servers and deliver a message for the corresponding recipients. It worked well enough for me at the time.
https://github.com/denvertimothy/ThriveSMTP
It's been a long time since I've used it, but I threw it up on Github just now.
I used http://www.mailerq.com/ which works cool. Its a queue based mail transfer agent. It requires rabbitmq.
It provides multiple worker as well.easy to store in database.
It provided management console as well.
worth to check it

Has Anyone Here ever tried PEAR

Hi I have been reading alot of articles adoring the PEAR mail package and it seems like PEAR is something I need to try out.
I am interested in setting up a full mail server, similar to a conventional SMTP mail service; which incorporates mail queuing, resending with a backend database etc. My impression is that PEAR can do this but can its service be used with mail clients like outlook to send mail, just as how any any smtp server daemon can where one would enter a portnumber, server name and/or security protocol?
Thanks
No, PEAR isn't going to magically solve these problems for you.
PEAR is a collection of PHP classes that are meant to solve common problems faced by PHP users. The Mail packages offer code for interacting with different parts Email systems. They do not contain code for creating email systems from scratch.
For example, form the Mail_Queue documentation
The Mail_Queue class puts mails in a temporary container, waiting to be fed to the MTA (Mail >Transport Agent), and sends them later (e.g. a certain amount of mails every few minutes) by >crontab or in other way.
The MTA in this case in sendmail, postfix, etc.
Another example, from the Mail_Mbox documentation
It can split messages inside a Mbox, return the number of messages, return,
update or remove an specific message or add a message on the Mbox
Incorrect use of "an" aside, you are using this to read existing MBOX files, and not caring how they got there.
The Mail package is about interacting with existing mail systems, NOT creating replacements. You'll still need to understand how all those email systems work to create a "full mail server, similar to a conventional SMTP mail service". If you're doing this because you want to learn how email systems work, have at it. If you're doing this because you thing this will give your business some leg up in the email game, I laugh and say "good luck with that"
PEAR is a repository for lots of libraries. Some of them deal with mailing.
PEAR's Mail class is designed for sending mail only. It is not designed as an implementation of an SMTP server.
Pear Mail is an SMTP sender aka client, not an SMTP server. Although it's entirely possible to write server (any kind of server) in php that doesn't mean that writing an SMTP server yourself is necessarily a good idea as it requires quite some expertise to do it right (spam anyone?). If you want to see an SMTP server implemented in a scripting language, go have a look at Lamson, written in Python by Zed Shaw.
And while you're there, do read the About page. This quote says it all
However, as great as Lamson is for
processing email intelligently, it
isn’t the best solution for delivering
mail. There is 30+ years of SMTP lore
and myth stored in the code of mail
servers such as Postfix and Exim that
would take years to replicate and make
efficient. Being a practical project,
Lamson defers to much more capable
SMTP servers for the grunt work of
getting the mail to the final
recipient.
It seems to me that PEAR's MailQueue package may address your needs.

Categories