Page MenuHomePhabricator

Fix sending email as user / via sendgrid.
Needs ReviewPublic

Authored by klimek on Aug 15 2014, 5:54 PM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Apr 24, 11:30 PM
Unknown Object (File)
Wed, Apr 10, 7:58 PM
Unknown Object (File)
Sat, Apr 6, 3:09 PM
Unknown Object (File)
Tue, Apr 2, 12:22 AM
Unknown Object (File)
Mar 20 2024, 4:41 PM
Unknown Object (File)
Dec 27 2023, 5:51 AM
Unknown Object (File)
Dec 25 2023, 5:59 AM
Unknown Object (File)
Dec 23 2023, 3:27 AM
Subscribers

Details

Reviewers
epriestley
Group Reviewers
Blessed Reviewers
Summary

As we're sending emails for users without actually being them, we need
to pretend to be a mailing list (otherwise DMARC will kill the emails). The
way to do that is setting the List-Id field.

PHPMailer/SMTP also needs 'quoted-printable', otherwise integration with
sendgrid will double all line breaks (see
http://stackoverflow.com/questions/6276181/extra-newlines-in-plain-text-emails-sent-via-sendgrid).

Test Plan

Running on our production instance.

Diff Detail

Repository
rP Phabricator
Branch
fix-mail-as-user
Lint
Lint Passed
Unit
Tests Passed
Build Status
Buildable 2248
Build 2252: [Placeholder Plan] Wait for 30 Seconds

Event Timeline

klimek retitled this revision from to Fix sending email as user / via sendgrid..
klimek updated this object.
klimek edited the test plan for this revision. (Show Details)
klimek added a reviewer: epriestley.
  • Is disabling metamta.can-send-as-user a reasonable alternative to "List-Id"?
  • Why aren't you using the PhabricatorMailImplementationSendGridAdapter if you're using SendGrid? (Because of T3435?)
  • The quoted-printable thing is specifically a bug/behavior unique to SendGrid, right, and has gone at least 3 years without being fixed? Are you tied to SendGrid? We've seen other long-lived/odd behavior from SendGrid (T3435, T4199) and now recommend MailGun in the documentation.
  • Is disabling metamta.can-send-as-user a reasonable alternative to "List-Id"?

Well, no :) Then the email is not from the user.

  • Why aren't you using the PhabricatorMailImplementationSendGridAdapter if you're using SendGrid? (Because of T3435?)

Yes, partly. The sendgrid API is basically very limited and their answer is "use smtp".

  • The quoted-printable thing is specifically a bug/behavior unique to SendGrid, right, and has gone at least 3 years without being fixed?

I must admit that I don't know whether the quoted-printable thing is a sendgrid, phpmailer, or different level problem. The one line of 'quoted-printable' is also pretty simple for us to keep in the branch until we can switch off SendGrid :)

Are you tied to SendGrid?

Not particularly :) I found it's working well for us, and has a pretty generous free tier (25k mails + incoming email forwarding, which we need)

We've seen other long-lived/odd behavior from SendGrid (T3435, T4199) and now recommend MailGun in the documentation.

I can take a look at MailGun. Not sure their free tier (10k mails / mo) is enough for us, I'll check. Thx for the pointer.

I pulled the quoted-printable bit into D10303, since another install hit this issue. Hopefully this doesn't break like 3 other mailers. :/

Awesome. So what about the rest? I'm happy with keeping this in our branch (I think it's never led to a merge problem), but I also think it's super useful to at least have documented somewhere if we don't want to put this into the main branch (it took me a day to figure out what the right solution is (after talking to some of my colleagues), so if somebody else hits this they'll probably also be wasting a lot of time on it; figuring out why mail is rejected is about the least fun thing one can work on).