Sendmail only sending some emails


#1

Hey all,
Since I started using a contact form on my website, I’ve had occasional complaints of emails not going through. I can’t think of any reason or pattern for the emails that go through vs. the ones that don’t… is there some sort of filtering that is happening maybe to prevent spam?

fwiw, the inbox that these go to are not filtered for spam so they aren’t being lost there.

The interim solution I’ve come up with has been to write all of the emails to a .txt file on the server in addition to sending them through php’s mail() so I can occasionally check the .txt file to see if there’s any emails I’ve missed.


#2

what is the FROM header? If you are using the email address submitted via the form, then that’s your problems, change the FROM header to be a valid email address on your account. You can include that email address from the form in the body, and/or set it as the “Reply-to” address, but you can’t use mail() to forge a from header, it must be from your domain.

Your not yahoo, you can’t send mail as yahoo. etc etc


#3

Strangely, it works for some domains and doesn’t work for others. Either way mail() is returning 1, claiming success.

FROM set to yahoo and google do not go through, but FROM set to microsoft goes through and I’m pretty sure I don’t own that domain name (unfortunately). FROM set to test.com seem to go through too, and that’s what I was using for most of my tests… stupidly.


#4

Just noticed that this is very similar if not identical to my issue.

Was there any resolution for this?


#5

As LakeRat said, I now put the users’ email address as the Reply-To: and I put a generic do-not-reply@mydomain.com as the From: and it seems to work good.

As a backup, I also write all the contact form submissions to a plaintext file that I check occasionally.


#6

I am also having the problem where I am not receiving all messages sent from forms on my sites. Dreamhost support is claiming it’s because of their spoofing policy, however, my forms have been working for years and in fact last worked on February 9th. The e-mail messages are sent using the e-mail address entered by the visitor and it has worked this way for years. I happened to test the form on the 11th and found it wasn’t working. Now today, it works, sometimes, and it doesn’t matter if the “from” e-mail is my dreamhost-hosted address, or not.

I have not changed anything in my code, and I’m still working with Dreamhost support to try to find the real problem. If it used to work and now doesn’t, and I haven’t changed any code, it has to be a issue with the servers.

Also, the spoofing reasoning doesn’t really make sense to me. If I have a form that sends e-mail to me, and it’s from whatever address the user enters (valid, or not), how can that be considered spoofing? I’m getting information from the user. All messages come to me (at my dreamhost e-mail account) and if I’m allowing a user to put in an e-mail address that hardly the idea behind spoofing.


#7

The point is if the policy did NOT exist, a criminal could buy a legitimate dreamhost account and send out emails FROM anyone TO anyone. That is you could email a few thousand people to change there bank password…etc Therefore email that comes from your account must be FROM your account.

Another way to look at this is your not yahoo, why should you be able to generate email that claims to have come from yahoo if you are not yahoo?

FWIW, I don’t know why but the anti-spam policy has existed since April 4th, 2012, but your not the first person to claim they have had no problems until suddenly things stop working.
[hr]
Also a simple way to resolve is change the FROM email address accordingly, then make the “Reply-To” address the person that filled out the form, then when you get the form email you can quickly hit the “reply” button and still be replying To the person that completed the form.


#8

Could you please explain me in details how to do that? I would like to try this way to solve my problem. Thanks!


#9

Right after your mail() call, put something like this line:

[php]file_put_contents ($_SERVER[‘DOCUMENT_ROOT’].’/contact.txt’ , "DATE: " . date(DATE_RFC2822) . "\nFROM: " . $replyto . “\n” . $contactmessage . “\n\n\n”, FILE_APPEND);[/php]

Obviously change $replyto and $contactmessage to whatever your variables are for those things.


#10

I’ve also had the file output into a folder under the domain, then protected that folder via the .htaccess file. That is:

–create a path such as $HOME/domain.com/pvt/
–use .htaccess in pvt/ to require user/password and/or whitelisted IP’s. Also turn indexes off in the same htacess.
–write contact.txt in pvt/

A non-techincal user can now access the file much easier, just point the browser to domain.com/pvt/contact.txt and either come via a whitelisted IP or supply user/pass to gain access.

… then I had the bright idea to have a cron task that the first minute of every month renamed contact.txt to contactYYYYMM.txt and created a new empty file :stuck_out_tongue: (of course make sure the value for MM is LAST month… i.e. when cron runs at 00:01 on 02/01 you want MM to be 01 (for january) because the entries in the file that your archiving are from January)… and don’t forget the jan 1st special case when LAST MONTH is YYYY minus 1 and MM=12):stuck_out_tongue:


#11

Thanks a lot !


#12

.htaccess - much better than my security through obscurity :slight_smile:


#13

I’ve gotten used to doing the same now, but slightly differently.

Instead of saving it to file, I use a mysql database and store the message data there, instead of sending the emails at all.
My site has a cron running that sends notifications of new messages every hour. I then just sign into my mail account and send replies from there.