How to sign emails to setup DKIM and DMARC After setting up my Drupal 8 site in the server, I noticed that none of the emails go to the inbox in Gmail and it all gets stored in Spam. Upon further investigation I found that this is because the emails are being sent via the PHP Mailer and its not being signed and authenticated.

I'm not that familiar with Drupal programming, therefore any suggestions and instructions on how I can get this configured via code/modules etc would be greatly appreciated.
Please check out the following two modules to have your Drupal mails send by a mailserver. Apart from that it may already be sufficient to just set a SPF record for your domain as DKIM and DMARC has actually nothing to do with Drupal.



PHPMailer

https://www.drupal.org/project/phpmailer


  Adds SMTP support for sending e-mails using the PHPMailer library.
  Comes with detailed configuration instructions for how to use Google
  Mail as mail server.


SMTP Authentication Support

https://www.drupal.org/project/smtp


  This module allows Drupal to bypass the PHP mail() function and send
  email directly to an SMTP server. The module supports SMTP
  authentication and can even connect to servers using SSL if supported
  by PHP.




How To use an SPF Record to Prevent Spoofing &amp; Improve E-mail Reliability

https://www.digitalocean.com/community/tutorials/how-to-use-an-spf-record-to-prevent-spoofing-improve-e-mail-reliability


  A carefully tailored SPF record will reduce the likelihood of your
  domain name getting fraudulently spoofed and keep your messages from
  getting flagged as spam before they reach your recipients.