Welcome to WebmasterWorld Guest from

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

mail() not working for all email accounts

Email not received at hotmail account



6:31 pm on Jun 16, 2007 (gmt 0)

10+ Year Member


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 <info@example.org>' . "\r\n";
$rheader .= 'Reply-To: Info <info@example.org>' . "\r\n";
$rheader .= 'Return-Path: info@example.org' . "\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)
(envelope-from <nobody@host.example2.net>)
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]


8:22 pm on Jun 17, 2007 (gmt 0)

10+ Year Member

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.


8:29 pm on Jun 17, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member

As well as the suggest above, you've got to look at your content. Don't forget to always add a "From: my company <no-replay@mycompanyssite.com>". 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)


5:36 am on Jun 18, 2007 (gmt 0)

10+ Year Member

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:

[mail function]
; For Win32 only.
;SMTP = localhost ;
smtp_port = 25

; For Win32 only.
sendmail_from = info@companyname.org ;

; For Unix only. You may supply arguments as well (default: "sendmail -t -i").
sendmail_path = /usr/sbin/sendmail -t ;



7:18 am on Jun 18, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member

Now I need a few details from you: Is your machine windows or BSD or *nix based?


8:59 am on Jun 18, 2007 (gmt 0)

WebmasterWorld Senior Member vincevincevince is a WebmasterWorld Top Contributor of All Time 10+ Year Member

That, I believe, is part of your SENDMAIL configuration or your server name configuration. I don't think you can override that by PHP.


9:15 am on Jun 18, 2007 (gmt 0)

10+ Year Member

We have linux server.


1:02 pm on Jun 18, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member

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).


2:27 pm on Jun 18, 2007 (gmt 0)

5+ Year Member

Pass the -f parameter to sendmail when sending mails.

mail('info@example.com', 'subject', 'message', null, '-f info@example.com');

If your Exim config is fine then this should work.



8:51 pm on Jun 19, 2007 (gmt 0)

10+ Year Member

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.


Featured Threads

Hot Threads This Week

Hot Threads This Month