php mail() often not reaching the address - php

this is my problem, essentially - I set up a wordpress contact.php template that would submit forms and send it to my gmail. However, the issue is that it reaches the email only less than half of the time, and it's imperative that I get the rest of the emails.
The next issue related to this is that I did not set up a file that would log the sent out messages. MY question is, basically, - is it possible in any way to retrieve the sent emails that haven't been logged? is there usually a cache of emails maintained by the hosting provider? The only information I have is the IP addresses, and that is hardly any help in this situation.
Thank you.

Probably being hit by your spam filter. PHP's mail() function is prone to this because the mail is sent from the web server, which isn't generally configured with SPL, etc, that receiving mail systems look for to help them filter out spam.
I don't think I can answer the question of how to retrieve lost messages that have already been sent -- only your hosting provider can really help you with that, but my guess would be that they can't help. They are very unlikely to keep hold of outbound emails any longer than necessary. If you're lucky, they might have logs of email events, but even that might not have any useful data in it for you.
One question though: Have you checked your gmail spam box? I'm not a gmail user, but most mail systems do keep a spam box with filtered messages, so that users can retrieve an email that gets marked as spam incorrectly. I'd be surprised if gmail doesn't allow that, and if that's where your mail has gone, then problem solved.
For the future, I suggest switching to use a decent third party library for your mail such as phpMailer.
The advantage of phpMailer for you in particular is that it can be configured to send mail via gmail, which means you can send it to yourself from own account. This should be pretty much bullet proof as far as spam filtering is concerned. It should also be delivered quicker, since the mail will go direct to Google's servers, without needing to bounce around the internet first.
phpMailer will also make your mail code much cleaner than using the raw mail() function, and it allows more advanced features like attachments, without having to write mountains of code.
Hope that helps.

Related

Mails not sending to outlook, hotmail

I have my site hosted on bluehost which sends out daily mails to customers (with cron jobs). All mails are working fine except outlook and hotmail. Customers are not getting emails on their outlook/hotmail accounts. I checked the code and it working properly, returning true with php mail function.
MX records on hosting are set to gmail, bluehost supports says its a code issue or I need to consult with google but when I send direct mail through gmail account customers are getting them.
I am not sure how to debug and resolve this issue. Can someone suggest me the ways to resolve this or the possible reason behind this.
I know this is a few months later, but maybe I can help. I fought with this for a while. It depends on the mailer you're using, and your code a bit so it would be best to post it here.
Overall though, outlook and hotmail have extremely high spam filters, so there's a list of things you need to consider.
First - I've heard third party mailers will get blacklisted or blocked pretty quickly (check their reviews), so check that the IP address hasn't been blacklisted. You can contact outlook to do this (good luck), or send yourself an e-mail, find your ip in the header of your e-mail, and check a blacklist checker online somewhere.
Second - As part of USA's CAN-SPAM Act of 2003, you need to provide some sort of unsubscribe link as well to be in the good books.
Third - If you are using phpMailer or something along those lines, you'll need to remove anything that looks like this:
$mail->AddReplyTo("youremail#domain.com");
$mail->From = "youremail# domain.com";
Because that will get it marked as spam.
Fourth - If you end up trying to send your e-mails through your gmail instead, allow access to third party apps, then go here (https://accounts.google.com/b/0/DisplayUnlockCaptcha), it will show up in your hotmail just fine.
Be warned that if you test your hotmail too often with the same message, it'll get blocked again.
Hopefully this helps!

What the best way to implementation email sending?

I have web application, and I want to implementation email system. My web application is a social network: users receive email when users update status and any another user is commented to their status.
What is the best way to implement that? I have been implement email system after users is comment, then in the same time I'm sending email to their user. The second option to use a schedule to send email.
I am using PHP and SwiftMailer.
To clarify: should I directly sent email to users, or should I use a database to queue mail and send via cron?
Please try phpmailer library functions
You could also try PostageApp.
http://postageapp.com/
You can use inbuilt php function .Please visit the following link.
http://php.net/manual/en/function.mail.php
My advice is to use a mailing service with an API, such as Sendgrid for large amounts of mails (>100 per day), and otherwise just use your php mailer of choice.
Sending mail via your own server has a couple of disadvantages, mainly related to getting blacklisted or marked as spam. This is because the other mail servers don't really know yours, and if suddenly a lot of mails start appearing, you look like a spambot.
To avoid sending a lot of mails at once, you also have to somehow queue the sending via batches, and for that you need cron jobs and such. Getting un-blacklisted is also not very easy, and simple domain changes will probably get you re-identified
Mailing services do relieve you of most of these problems, and are overall reasonably cheap. Learning the pitfalls of in-house mail solutions is usually too much for a single project, since it is a reasonably large topic.
Disclaimer: I do not work for any mail-sending service, I just happen to work in a place that had their domain blacklisted recently because of bad emailing practices.

PHP emails via SMTP: what is HELO, how to setup to avoid being SPAM

On a website with about 1300 Users I've set up that emails for confirming your email address, etc are being sent with phpmailer via a gmail account (google smtp), which worked very well for the first 2 month.
Now, recently a bigger and bigger amount of users complain they do not receive any emails anymore, not even in the Spam folder.
While I have no problem receiving any when I try it myself, I found that it especially concerns certain providers (or let's say a wide variety of providers, just not gmail itself).
Then I found this article: php mail() Goes to spam but when sent via SMTP Server it works fine?
I do not really understand what Gryphius (the accepted answer) talks about. I've read in the Google Guidelines for avoiding SPAM (don't remember how they are called exactly), about HELO and A-records, but don't know what they are. Could anybody explain me what it is and how to do that?
What else can be done to send emails from shared hosting and ensure they most all reach their recipients?
Thank you very much already in advance for your help!
UPDATE: This information I found in the header, what could you tell from this?
X-Acl-Warn: X-DNSBL-JUNKEMAILFILTER
X-Spam-Score: -0.3

SMTP or PHP mail on VPS ( Or Physical Severs) - A Social Networking site

I am developing a social networking site. It has functionality like user registration, people exchanging messages and sending email notifications for people's actions (and many more).
Currently I use PHP's mail function to send mails and it is working fine. I already set up a VPS and hosted the application.
My question may be a dumb question. Do Facebook and other social networking sites use SMTP servers to send the notifications or only just any kind of PHP mail function?
I read somewhere that using PHP's mail, there is a chance of mail going to SPAM folder. They advised using a certified SMTP server.
So, if I have to use an SMTP server:
1) Do I have to purchase a certified SMTP server separately? Or can this be hosted on same VPS whatever I have. If so, what server software will be good for this?
2) Are there settings I have to do in SMTP servers like send unlimited messages, because we don't know how many people exchange emails in a minute, and that is totally random.
To start: you are definitely going to have to use an SMTP server to send the emails from PHP. You can't simply throw your emails at the mail() function and expect it to work. You have to connect it to an SMTP server that does all of the dirty work.
However, if it's not your domain, I would suggest you don't do it. If you have the time to learn the ins and outs of email delivery and want to set up and maintain an SMTP server, by all means, go ahead.
If you'd rather focus on building your app and not worry about your emails getting delivered, I'd suggest an email delivery service. Here's a good list of services to check out:
PostageApp
Sendgrid
Postmark
Mailjet
And there are plenty more out there. All of them have a free option for you to play around with, so just look for the one that fits your needs and requirements.
(FULL DISCLOSURE: I am the Product Manager of PostageApp. Happy to answer any questions you might have about sending email from your app, though!)
The issue here is not really with the mail() function in itself, but in how you construct the emails. Messages can be treated as spam for a million and one reasons, but it is generally accepted that if you use one of the tried and tested mailer libraries, like Swiftmailer or PHPMailer (both free) there is marginally less chance of your messages being treated as spam.
Whether your messages get treated as spam is far more about how you construct your messages than how you send them. Another major factor is if your server sends thousands and thousands of emails all the time, so another hint is to be sparing with the emails you send out - only send them when you actually need to.
If you really want to know the answer to this question, you should do some reading on exactly how the modern email system works. Being able to build and send good emails is all about knowing how to work the system. Start here.

Fast email delivery

I have a website that receives incoming emails via cloudmailin, adds the content to the database, and then sends a confirmation email back to the person who sent the email. Currently I'm using a php mail() function to send the reply, but it seems to take about 1.5 min to actually get to the user's inbox. Is there a way to make this more instantaneous? I'm currenly hosting the application on FatCow, and I'm sure it has to do with their mail server, but I don't really know much about how that works and am wondering if I have to change hosts to accomplish faster delivery times or if I can do anything about it without switching.
mail() is a black box. You're telling PHP to try sending a mail however the host has configured PHP to do so.
It's very likely that it's just calling sendmail in your case. It's also very likely that the mail queue on that machine isn't the fastest in the world. Shared hosting machines are often overloaded.
The very first thing you should do is ask your host about the mail delay. Perhaps something is wrong, and they can fix it. Or they might just tell you that a minute and a half is not a long time to wait.
There are lots of other options, mostly in the form of companies that provide an SMTP service to you. I can't recommend one, but I can recommend that you pop over to your favorite search engine and look for "smtp service." I've recently starting working with Amazon Simple Email Service. It's supposed to be fast and well-maintained, and it's certainly inexpensive.
All of those options are likely going to require some configuration changes on your end. For example, you'll want to set up custom DNS records (for DKIM and SPF) to ensure that mail from a third party provider isn't automatically flagged as spam.
Using SMTP with PHP is dead easy. There are plenty of mail generating options out there. My personal favorite is SwiftMailer. It even has a transport option for Amazon SES.
The final option, of course, is grabbing your own virtual private server or dedicated server, which will let you configure outgoing mail as you desire, at the cost of needing to know how to maintain that server.
Edit: Obligatory link to relevant Coding Horror post.

Categories