Q: Problems sending email with PHP on Linux I have a script I have created to email customers their order confirmation when they place an order. It is a simple PHP mail() script. This is also being done on a shared linux host.
My problem is that the script will be received 10 times, then it will stop being received (by any email account) for a long period of time, and then all of a sudden they will start being received again.
I've contacted my host with this issue and they told me a few things that I think are just wrong due to ignorance. The first is that the emails are probably being blocked by the email provider. If that was the case, I wouldn't imagine 10 would come through on 3 different email servers (aol, gmail, hotmail) and then suddenly stop. They also say that their emails go out in batches, which I do not believe applies to customer scripts. If that was the case they wouldn't be instantly received when I run my script half the time. Also, during these dry spouts when the emails aren't received by any host, those emails never come in. And third they told me to use their webformmailer.php which will use their system of batch emailing. The problem is, their webformmailer only allows me to send emails to one predetermined email (as in I have to set it up in controlpanel).
So I have a few questions: How much of this problem is related to my host, my script, and email providers? What are some fixes to make email more reliable? I've been experimenting with some email libraries like swiftmailer but they don't seem to improve the situation.

A: It sounds like your hosting provider set a maximum number of emails per minute/hour or something. It looks like it's blocked by the providers server.
So a solution would be to just use an other smtp server not the mail() default.

A: If you're on a shared host, don't use mail(), it will never work the way you want for a few reasons:


*

*Hosts usually put limits on the number of messages you can send, this might be global to everyone you're sharing a server with.

*Larger email providers might have seen spam from the IP you're using now and might be rate limiting you.

*Large email providers might also just be blacklisting your IP so some email will never even arrive.


If you have access, check your web server error logs, mail() will log any error responses there so you can see if you are getting a TEMPORARILY DEFERRED from the host you're sending the mail to.
My advice would be to use either an SMTP connection to an email host you can send messages through or some other external email service.
