Reputation: 20049
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?
Upvotes: 9
Views: 6854
Reputation: 17004
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:
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.
Upvotes: 3
Reputation: 6832
http://php.net/manual/en/function.mail.php
The Windows implementation of mail() differs in many ways from the Unix implementation. First, it doesn't use a local binary for composing messages but only operates on direct sockets which means a MTA is needed listening on a network socket (which can either on the localhost or a remote machine).
On linux the sendmail executable is used to talk to the SMTP server configured on windows you can / could configure mail()
function to use SMTP
So the best way is to use SMTP directly to send the email to Gmail to send the email.
Taken from: https://stackoverflow.com/a/33506709/623150
Here is a way to do it with PHP PEAR
// Pear Mail Library require_once "Mail.php"; $from = '<[email protected]>'; //change this to your email address $to = '<[email protected]>'; // change to address $subject = 'Insert subject here'; // subject of mail $body = "Hello world! this is the content of the email"; //content of mail $headers = array( 'From' => $from, 'To' => $to, 'Subject' => $subject ); $smtp = Mail::factory('smtp', array( 'host' => 'ssl://smtp.gmail.com', 'port' => '465', 'auth' => true, 'username' => '[email protected]', //your gmail account 'password' => 'snip' // your password )); // Send the mail $mail = $smtp->send($to, $headers, $body);
If you use gmail smtp remember to enable SMTP in you gmail account, under settings
On a Linux Server you can't use SMTP via the mail function.
Upvotes: 0
Reputation: 3031
When you use GSUITE for hosting emails, it's obvious that you will be providing some domain name to GSUITE.
Now emails are marked spam and not spam based on the content as well as certificates of sending server and sending servers have different services for Transactional and Marketing Oriented emails. And GSUITE only provide transactional mail service, and transactional mails from a mail service --having valid certificates and not black listed-- lands directly into Inbox or Other Label, but Spam/Promotion.
Now GSUITE is having all correct certificates and I don't think there is any consumer oriented mail service provider, which blocks emails coming from google servers.
Other Question:-
Does the From Address
in E-MAIL headers matters?
Upto now I have never seen from address impacting anything on receiving servers, but some consumer mail services block the usage of from address other than the account email address, just like mobile operators don't let us use someone else's caller id(Ideally).
But mail service providers to businesses let you use any address as from
value in e-mail headers.
Edit:- If you are still unsure about delivery of emails, you can use replyTo header with out any problem.
PS:- I have tested this myself with thousands of emails but using SendGrid servers.
Upvotes: 0