Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
152 views
in Technique[技术] by (71.8m points)

php - can't send email to addresses at my own domain

I have a simple php script on my domain that sends me an email:

...
$toMail = "[email protected]"; //this works - I get the email at my gmail
$toMail = "[email protected]"; //this doesn't - I get nothing

mail($toMail, $subject, $message, $header); 

What setting to I change to fix this?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

For the people using Google Apps for email, but having your host in other provider this are more detailed instructions for the people that is not very familiar with cPanel.

I could fix the problem of sending email from my domain using a PHP form, when sending the email to an account inside my domain.

i.e. mydomain.com Contact form sending email to [email protected]. The above was not working even if my domain has the correct MX records for the domain using Google Apps.

As Mike noted (and others) above the problem was solved: Adding the MX records into the cPanel.

  1. Enter into the cPanel
  2. Go the the cPanel Mail section
  3. Search for MX Entry Maintenance, sometimes there is no text above the icon.
  4. Select the related domain
  5. Change Email Routing to Remote Mail Exchanger.
  6. Add all the google MX records as they are in your domain configuration using the appropriate priority values. You can check the records here and priorities https://support.google.com/a/answer/174125
  7. Double check that Remote Mail Exchanger. is selected.

With this setting I was able to send email using mail PHP function to an email account inside the same domain as my website.

Google App instructions talking about MX records https://support.google.com/a/answer/54717?hl=en


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...