Php mailer problem


I have a website that needs to send emails using php mailer, it stopped sending the emails I have managed to fix half the problem but it is still not sending all the emails.
Is this something I could get help with here?

Many thanks

Kinda tough to help out without seeing any code, knowing your environment, or what you’ve done to troubleshoot this. Here’s a checklist I posted at Stack Overflow that should be helpful in troubleshooting this. If after running through this you still have issues come back and give us more information.

Make sure error reporting is enabled and set to report all errors
Error reporting is essential to rooting out bugs in your code and general errors that PHP encounters. Error reporting needs to be enabled to receive these errors. Placing the following code at the top of your PHP files (or in a master configuration file) will enable error reporting.

ini_set('display_errors', 'On');

Check your server’s mail logs
Your web server should be logging all attempts to send emails through it. The location of these logs will vary (you may need to ask your server administrator where they are located) but they can commonly be found in a user’s root directory under logs. Inside will be error messages the server reported, if any, related to your attempts to send emails.

Don’t use the error suppression operator
When the error suppression operator @ is prepended to an expression in PHP, any error messages that might be generated by that expression will be ignored. There are circumstances where using this operator is necessary but sending mail is not one of them.

If your code contains @mail(…) then you may be hiding important error messages that will help you debug this. Remove the @ and see if any errors are reported.

Check to see if mail() returns true or false
The mail() function:

Returns TRUE if the mail was successfully accepted for delivery, FALSE otherwise. It is important to note that just because the mail was accepted for delivery, it does NOT mean the mail will actually reach the intended destination.

This is important to note because:

If you receive a FALSE return value you know the error lies with your server accepting your mail. This probably isn’t a coding issue but a server configuration issue. You need to speak to your system administrator to find out why this is happening.

If your receive a TRUE return value it does not mean your email will definitely be sent. It just means the email was sent to its respective handler on the server successfully by PHP. There are still more points of failure outside of PHP’s control that can cause the email to not be sent.
So FALSE will help point you in the right direction whereas TRUE does not necessarily mean your email was sent successfully. This is important to note!

Check your spam folders / Prevent your email from being flagged as spam
Oftentimes, for various reasons, emails sent through PHP (and other server-side programming languages) end up in a recipient’s spam folder. Always check there before troubleshooting your code.

To avoid mail sent through PHP from being sent to a recipient’s spam folder, there are various things you can do, both in your PHP code and otherwise, to minimize the chances your emails are marked as spam. Good tips include:

-Use email authentication methods, such as SPF, and [URL=“”]DKIM to prove that your emails and your domain name belong together, and to prevent spoofing of your domain name. The SPF website includes a wizard to generate the DNS information for your site.
-Check your [URL=“”]reverse DNS to make sure the IP address of your mail server points to the domain name that you use for sending mail.
-Make sure that the IP-address that you’re using is not on a blacklist
-Make sure that the reply-to address is a valid, existing address.
-Use the full, real name of the addressee in the To field, not just the email-address (e.g. “John Smith” <> ).
-Monitor your abuse accounts, such as and That means - make sure that these accounts exist, read what’s sent to them, and act on complaints.
-Finally, make it really easy to unsubscribe. Otherwise, your users will unsubscribe by pressing the spam button, and that will affect your reputation.

Make sure you supply mail headers
Some spam software will reject mail if it is missing common headers such as “From” and “Reply-to”:

$headers = array("From:",
    "X-Mailer: PHP/" . PHP_VERSION
$headers = implode("\\r\
", $headers);
mail($to, $subject, $message, $headers);

Make sure your mail headers do not have a syntax error
Invalid headers are just as bad as having no headers. One incorrect character could be all it takes to derail your email. Double-check to make sure your syntax is correct as PHP will not catch these errors for you.

$headers = array("From", // missing colon
    "Reply To:",      // missing hyphen
    "X-Mailer: "PHP"/" . PHP_VERSION      // bad quotes

Send to multiple accounts
To help rule out email account issues, send your email to multiple email accounts at different email providers. If your emails are not arriving at a user’s Gmail account, send the same emails to a Yahoo account, a Hotmail account, and a regular POP3 account (like your ISP-provided email account).

If the emails arrive at all or some of the other email accounts, you know your code is sending emails but it is likely that the email account provider is blocking them for some reason. If the email does not arrive at any email account, the problem is more likely to be related to your code.

Make sure your Web host supports sending email
Some Web hosting providers do not allow or enable the sending of emails through their servers. The reasons for this may vary but if they have disabled the sending of mail you will need to use an alternative method that uses a third party to send those emails for you.

An email to their technical support (after a trip to their online support or FAQ) should clarify if email capabilities are available on your server.

If on localhost, make sure you have a mail server set up
If you are developing on your local workstation using WAMP, MAMP, or XAMPP, an email server is probably not installed on your workstation. Without one, PHP cannot send mail by default.

You can overcome this by installing a basic mail server. For Windows you can use the free Mercury Mail.

You can also use SMTP to send your emails.

Consider using an alternative mailer
PHP’s built in mail() function is handy and often gets the job done. But there are alternatives that offer more power and flexibility including handling a lot of the issues outlined above. One that would might consider using is the popular PHPMailer.


thank you very much for your very detailed reply.
I’m not a coder so your reply has lost me.
I have attached the email script
It should send an email to the customer, admin and 2 to restaurant.
It is only sending the customer email and admin.
It is not sending the restaurant emails.
If you could have a quick look it would be great.
I’m trying to find out if it is a code problem or spam problem.

Thanks for your detailed reply.
I have attached the problem script i’m trying to establish if the problem is code or spam

the script

I uploaded the wrong script just now

Looks code to me, though I can’t understand why you’re messing around in files if you’re not a coder, you could accidentally change something without realising what you’re doing and cause a whole heap of problems


I have not touched the code at all.

Trying to send too many in one go?

My host has a limit of 50 per batch. I don’t send that many out so it isn’t a problem for me.

A little background
The website was working fine for 2 years then stopped
Sending emails hosting said it was being blocked as spam
And to enable stmp
I did this then the site is send customer and admin
Emails but not the 2 to the restaurant.
I’am capable of changing code if shown what code needs
Changing but if the script is fine is it still a spam issue
Any help would be great.

Many thanks

Sometimes even the emails with the best intentions get blocked, so I wouldn’t worry too much, unless it’s blocking all the mail.

And what is it being blocked by? By a web based email service like yahoo or gmail?


I’m still confused with my site sending half the emails. I have attached the part that is not sending.
If I can find something wrong with the script I can move forward.
If someone could just tell me if it is wrong or not would be great.

Thanks for your time