|mail() not working for all email accounts|
Email not received at hotmail account
I am using mail() function on Apache server.
My header entries are as follows:
$rheader = 'MIME-Version: 1.0' . "\r\n";
$rheader .= 'To: ' . $toemail . "\r\n";
$rheader .= 'From: Info <email@example.com>' . "\r\n";
$rheader .= 'Reply-To: Info <firstname.lastname@example.org>' . "\r\n";
$rheader .= 'Return-Path: email@example.com' . "\r\n";
The function is working well. I am receiving mails to my account. But for some email accounts specifically HOTMAIL I am not able to send mails. It is not even coming to its Junk folder. What could be the problem? Do I have to add some more entry to the header?
In the received mails the header entry are:
X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.1.7
Received: from nobody by host.vps92.sgvps.net with local (Exim 4.63)
id 1HzZ09-0007ua-E3; Sat, 16 Jun 2007 10:11:41 -0400
Is this NOBODY in "Received: from" a problem? Please guide me what should do?
Thanks in advance.
[edited by: eelixduppy at 12:52 am (utc) on June 18, 2007]
[edit reason] example.com [/edit]
There are many threads on WebmasterWorld about non receipt of emails to Hotmail addresses.
You need to find out if your server's IP address is blacklisted. And then you need to find out if your server has valid PTR records. The latter two points all contribute to hotmail (and others) determining if your email is spam.
As well as the suggest above, you've got to look at your content. Don't forget to always add a "From: my company <firstname.lastname@example.org>". Make sure that your MX records and server IPs are not blacklisted, even graylisted! Also, make sure that SNMP (that's the function that mail uses to send mail, on *nix and BSD it is) is running under the correct user so you don't get NOBODY var anymore (it should be yourserver.yourisp.com)
Thanks for your suggestions.
Ahmedtheking could you please tell me how can I configure SMTP to apache server. I have following lines in php.ini at present:
; For Win32 only.
;SMTP = localhost ;
smtp_port = 25
; For Win32 only.
sendmail_from = email@example.com ;
; For Unix only. You may supply arguments as well (default: "sendmail -t -i").
sendmail_path = /usr/sbin/sendmail -t ;
Now I need a few details from you: Is your machine windows or BSD or *nix based?
That, I believe, is part of your SENDMAIL configuration or your server name configuration. I don't think you can override that by PHP.
We have linux server.
No it can't be overwritten by PHP, that's why we need to adjust your SNMP settings. Now SNMP is the protocol that sendmail should use in order to send its emails. Because you're not using an SMTP server, you run the risk of looking like junk mail.
You need to look at the users and groups for your server. For example, within the group (say) www would be Apache, PHP, etc... Now, when it comes to sendmail, it should be running as the logged in user, ie 'webserver' (not to be mistaken with www). A reason why you're getting NOBODY@YOURDOMAIN is that sendmail may not have the proper permissions to give itself a name or may not belong to the right group.
So what's the best way? Instead of tinkering and wasting time and maybe causing more problems, I'd suggest you reinstall the whole web server (not the OS) through RPM [rpm.org...] With RPM, you can install and uninstall things nice and easy and add filters. This makes everything a lot less messy.
I, being on a BSD based system, use DarwinPorts and RPM is pretty much the same. Where I would install a web server on DarwinPorts like so:
sudo port install php5 +apache2 +snmp +pcre +mysql5 (You can see how you can add items that can link into the installation with +)
RPM works the same: [rpm.org...]
Now you may be thinking "What?". But trust me. Instead of us going back and forth finding the route of your problem here, it's better to just reinstall it and in a more 'sustainable' way (such as Darwinports and RPM).
Pass the -f parameter to sendmail when sending mails.
mail('firstname.lastname@example.org', 'subject', 'message', null, '-f email@example.com');
If your Exim config is fine then this should work.
Your webhost may restrict outgoing email sent to domains through the local mail function other than those on the root server. This can be quite common in an effort to prevent SPAM.
If this is the case, it is unlikely the host will remove this restriction but you can always ask ;-).
Otherwise you can either, get a new webhost that will allow sending of mail from script to other domains, or you can just place the mail script on another server and call it through the cURL function on your website.
You can also use cURL to connect to an smtp server on a Linux server. You will need an smtp relay that allows incoming connections via web - one that does allow this is Gradwell.
If you are scripting to send to external domains through variables, you must ensure your script is secure - it would be a Spambots dream to find it.