Nobis
Nobis

Reputation: 21

PHP mail is not being sent from exmaple.com to the Google Apps email [email protected]

When I am trying to send a mail from a contact form in my website using the
PHP mail function its not sending from example.com to the Google apps email [email protected].

Upvotes: 1

Views: 881

Answers (3)

user737133
user737133

Reputation: 9

Just modify the /etc/hosts file and add your IP Address example.com example in the next line, this should work by routing emails to google's servers .I did the same for my site.

So my /etc/hosts file looks like this :

127.0.0.1 localhost IP mysite.com mysite(this is an alias and you can call it anything i suppose)

Upvotes: -1

Abhishek Balani
Abhishek Balani

Reputation: 3803

After a very long research, I found the answer to this problem.

For me, the problem is in my host settings.

You host treats those domain addresses as they were registered with itself not with Google Apps. So it routes the emails to hosts mail server.

To route it through Google Apps (Gmail), you need to change the email routing settings.

Find "MX Entry" settings in your cpanel and add a new MX Record with priority

0

and destination

gmail.com

and add it. You should also change the existing MX Record priority to 1.

These settings will let your receive emails from php mail() to your Google Apps gmail account.

Upvotes: 1

user1438599
user1438599

Reputation:

To send email from PHP you must have an SMTP server installed and have PHP configured to use the server. If you are using shared hosting or have it set up, you should check that you are calling the mail function correctly by checking the documentation.

Here is an example of how it is used:

$to = "[email protected]";
$subject = "Test Message";
$message = "Hello!";
$headers = "From: [email protected]";

mail($to, $subject, $message, $headers);

Upvotes: 0

Related Questions