Welcome to WebmasterWorld Guest from 54.147.134.218

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

PHP Site Will Not Send Mail to Own Domain

     
2:13 am on Jul 12, 2014 (gmt 0)

Junior Member

5+ Year Member

joined:Mar 20, 2008
posts: 172
votes: 0


Hi all, I've just added mail to my website hosted and the following is happening with mail:

- Email sent from private email (i.e. @gmail.com ) to @mydomain.com is received
- Email sent from PHP mail() to private mail is received
- Email sent from PHP mail() to @mydomain are NOT RECEIVED

I have the following default settings in php.ini:

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

My script that I am testing with is very basic:

$to_address = "example@mydomain.com";
$subject = "This goes in the subject line of the email!";
$message = "This is the body of the email.\n\n";
$headers = "From: example@mydomain.com\r\n";
mail("$to_address","$subject","$message","$headers");

Is there a setting I need to change for this to work, or should be looking for?

I have checked junk mail and the mail is not being received there either.
2:46 am on July 12, 2014 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member lucy24 is a WebmasterWorld Top Contributor of All Time Top Contributors Of The Month

joined:Apr 9, 2011
posts:12711
votes: 244


The word "gmail" jumped out at me. Are you checking the email directly, or does it forward to your gmail address? This is crucial, because there's a gmail issue. (Not a bug, an intentional behavior.)
3:11 am on July 12, 2014 (gmt 0)

Junior Member

5+ Year Member

joined:Mar 20, 2008
posts: 172
votes: 0


No, I am checking email directly in webmail on the server @mydomain.com. No forwarding.
10:14 pm on July 12, 2014 (gmt 0)

Senior Member

WebmasterWorld Senior Member penders is a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month

joined:July 3, 2006
posts: 3123
votes: 0


Sorry to post "just a link", but this question over on StackOverflow seems to have some good suggestions:

can't send email to addresses at my own domain [stackoverflow.com]

Post back if something here solves it, or you still have problems.
4:50 pm on July 17, 2014 (gmt 0)

Administrator

WebmasterWorld Administrator coopster is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:July 31, 2003
posts:12533
votes: 0


If you are sending mail from your domain to your own domain on the same server you may need to adjust the host routing record (on my server it is in /etc/hosts)
You will need to add the internal IP along with the host name of your server and/or an alias if you have created one. For example, "mail" below is an alias and let's say your internal IP adapter address is 192.168.1.50 ...
192.168.1.50  my.server.name mail
 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members