3

I have a Google Apps Script attached to a spreadsheet, and it uses MailApp.SendMail().

   MailApp.sendEmail(recipient, subject, body, {
     noReply: true,
     htmlBody: htmlBody,
     name: emailFromName,
     replyTo: replyToEmailAddress,
     cc: ccEmailAddress
     });

I am running this from an account under my own domain myowndomain.com I'm using gmail to manage the email from this domain.

I have SPF and DKIM configured and they work in general. My DMARC is currently set to Quarantine, but I want to move it to Reject.

If I send mail from my personal outbox, either through gmail or another mail client through IMAP, everything is fine. SPF, DKIM and DMARC all pass.

However, any mail that is sent from the script passes SPF but fails DMARC. I don't think that DKIM is being triggered. From what I've read it's because the SPF check is from google's domain and the DMARC is from myowndomain.com.

Received-SPF: pass (google.com: domain of blahblah@maestro.bounces.google.com designates xxx.xxx.xxx.xxx as permitted sender)

dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=QUARANTINE) header.from=myowndomain.com

I have to believe that other people have done this and that there's a solution.

Is there a way to configure either the script or my DMARC/DKIM/SPF records so that they pass and my script-generated messages don't end up in spam?

Brad
  • 39
  • 2
  • Perhaps you should consider reporting this as an issue – Cooper Jun 12 '21 at 17:53
  • Hello @Brad! Could you please share the [code](https://stackoverflow.com/help/minimal-reproducible-example) you are using so that we can better help you? And please remember to remove or anonymize any private information. – Jacques-Guzel Heron Jun 14 '21 at 06:56
  • Hi Jacques-Guzel. Thank you for the help and for the suggestion. I didn't include any code because I believe it's a configuration problem as opposed to a code problem. I just added the code snippet, basically the one line of code, based on your feedback though. – Brad Jun 24 '21 at 00:58
  • Hi Brad, I have the same problem. Did you find a solution? Thanks – bastien Apr 21 '22 at 08:32
  • You can check for yourself by viewing the raw email header. For example, here's one that failed while sending from `MailApp.sendEmail()`: `dkim=pass header.i=@your-domain.20221208.gappssmtp.com header.s=20221208; spf=pass smtp.mailfrom=maestro.bounces.google.com; dmarc=fail(p=QUARANTINE) header.from=your-domain;` -- my hunch is you also have a DKIM/DMARC misalignment. [More info](https://easydmarc.com/blog/why-is-dmarc-failing/) – thdoan Jul 09 '23 at 05:14

0 Answers0