Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Externally hosted email and using PHP to send email

I will be using G Suite (formally Google Apps) to host the email of a site that runs off a separate host.

However, there is a contact form on the website, I haven't looked at it yet, but I assume it will use the standard mail() function.

As I understand it mail() will still use the servers mail server to send the mail, it may be a dumb question, but I assume this won't cause any spam detection issues because of this? Like, I know some servers won't accept mail if the From and/or Sender headers don't match the server it is coming from (or in some cases if the email you set in these headers doesn't exist).

So, if the mail is hosted on G Suite, and the email address that is setup in the From/Sender headers exists on G Suite this won't cause any issues correct?

Lastly, I know it's probably a better idea to use SMTP to send the mail via Google, but I may not have that choice, so I wanted to find out the answer to the above just in-case.

Edit: As per Nima's answer, is this something that can be avoided, or only with using Googles SMTP server to send with?

like image 853
Brett Avatar asked Aug 04 '17 07:08

Brett


1 Answers

If you want it simple, then simple use SMTP.

Because of spam, multiple mail server provider are blocking mails from mail servers that have no correct RDNS (Reverse DNS) and MTA name configured.

You want to make sure that all three names are matching according to your MX Record:

  • Sender Hostname (e.g *[email protected], note that from can be what ever you want)
  • MTA-Name/HELO-Hostname (Configured in Mailserver, e.g demohost.com)
  • RDNS (Basicly it gives per IP-Adress the Hostname (e.g 42.42.42.42 -> demohost.com)

Also make sure your php.ini has the correct configuration for your Mail Server. Congrats you can now send Mails using mail(...).

As I said, it's probably most simple by just using SMTP. Assign the hard work to a hoster.

like image 166
Christian Gollhardt Avatar answered Oct 16 '22 20:10

Christian Gollhardt