If you don't do this your host will try to deliver the mail locally as the default is to associate all domain settings with the host, typically with a @ mx record for the localhost. Below is a sample failed email from a webhost without the google mx records setup.
EMAIL FAILURE SAMPLE
Return-Path: <>
Delivered-To: webhostusername@mtl-node3.websitehostserver.net
Received: from mtl-node3.websitehostserver.net
by mtl-node3.websitehostserver.net with LMTP id 8GQACpV7fVynYi8AqIeWRg
for
Return-path: <>
Envelope-to: webhostusername@mtl-node3.websitehostserver.net
Delivery-date: Mon, 04 Mar 2019 14:25:09 -0500
Received: from mailnull by mtl-node3.websitehostserver.net with local (Exim 4.91)
id 1h0tD3-00D8fw-3q
for webhostusername@mtl-node3.websitehostserver.net; Mon, 04 Mar 2019 14:25:09 -0500
X-Failed-Recipients: yourdomainemail@domain.ca
Auto-Submitted: auto-replied
From: Mail Delivery System
To: webhostusername@mtl-node3.websitehostserver.net
Content-Type: multipart/report; report-type=delivery-status; boundary=1551727509-eximdsn-1324812479
MIME-Version: 1.0
Subject: Mail delivery failed: returning message to sender
Message-Id:
Date: Mon, 04 Mar 2019 14:25:09 -0500
--1551727509-eximdsn-1324812479
Content-type: text/plain; charset=us-ascii
This message was created automatically by mail delivery software.
A message that you sent could not be delivered to one or more of its
recipients. This is a permanent error. The following address(es) failed:
yourdomainemail@domain.ca
No Such User Here
--1551727509-eximdsn-1324812479
Content-type: message/delivery-status
Reporting-MTA: dns; mtl-node3.websitehostserver.net
Action: failed
Final-Recipient: rfc822;yourdomainemail@domain.ca
Status: 5.0.0
To enable google mail forwarding we need to setup mx records that point to google to do this you go into you login to your cpanel
You need to modify your domain zone on the host. Select Zone Editor
If there are any MX records setup, delete them. Then add the following using zone editor. (change domain.ca to your domain). You can also reference this google kb https://support.google.com/a/answer/140034?hl=en
Name | TTL | Class | Type | Record |
---|---|---|---|---|
domain.ca | 14400 | IN | MX | Priority: 1 Destination: aspmx.l.google.com |
domain.ca | 14400 | IN | MX | Priority: 5 Destination: alt1.aspmx.l.google.com |
domain.ca | 14400 | IN | MX | Priority: 5 Destination: alt2.aspmx.l.google.com |
domain.ca | 14400 | IN | MX | Priority: 10 Destination: alt3.aspmx.l.google.com |
domain.ca | 14400 | IN | MX | Priority: 10 Destination: alt4.aspmx.l.google.com |
then save your changes. You should now be able to send email to within your organization, but to make it a little bit more secure you should login to your google admin account and limit the scope of your third party hosted server. To do that go to
Now you would need to verify that your host supports pear php if you want to use smtp authentication as for TLS you will need to verify your host supports that as well.
The same applies to Office 365 if your using it
Name | TTL | Class | Type | Record |
---|---|---|---|---|
@ | 3600 | IN | MX | Priority: 1 Destination: MS=ms XXXXXXXX **Note:**This is an example. Use your specific Destination or Points to Address value here, from the table in Office 365. How do I find this? |
There are other settings you can include such as SPF if your host supports it.
These settings should allow you to email use php sendmail for google apps and office 365.
References:
https://support.google.com/a/answer/140034?hl=en
https://docs.microsoft.com/en-us/office365/admin/get-help-with-domains/create-dns-records-at-any-dns-hosting-provider?view=o365-worldwide
https://docs.microsoft.com/en-us/office365/admin/dns/create-dns-records-at-godaddy?view=o365-worldwide