ogallagher / tejos_textiles

An online arts journal for publishing works in a new medium
MIT License
1 stars 0 forks source link

Enable email server #17

Closed ogallagher closed 4 years ago

ogallagher commented 4 years ago

Currently the email template system is set up as a .json file of html and plaintext versions of each template. However, it will be a pain to edit these in the future, so I will move to creating an html and txt file for each template.

The email server itself has the nodemailer module set up to create and use a transporter with a test account but not with a real one that requires credentials/tokens.

ogallagher commented 4 years ago

Mail hosting options

Inlining CSS for better mail client support

Use Juice

ogallagher commented 4 years ago

Sending email through Sendgrid from my personal email address is currently working; though the Apple mail client is sending all of them to the spam folder.

ogallagher commented 4 years ago

Sending email through Sendgrid using my custom domain doesn’t work yet... it looks like it won’t actually be a mail server; just a way to send emails automatically through it, which is a big disappointment...

So, I will try ~Bluehost (requires purchase of domain through them)~ Rackspace next, and perhaps still send emails with it using Sendgrid, depending on how well it works.

ogallagher commented 4 years ago

Rackspace ended up being $10/mo, which is $120/yr. That is also disappointing since it initially seemed like $36/yr, but I’ll stick with it since this setup seems like it will actually work.

UPDATE: It’s working! At least for manual emails, I can send from contact@textilesjournal.org. Next up is to send automatically through Sendgrid.

ogallagher commented 4 years ago

As of now I’ve not been able to send an email to myself as contact@textilesjournal.org via Sendgrid. However, the whole sending pipeline is very slow, so I will probably cut out Sendgrid as the middleman between the web server and the email server, and instead try to use nodemailer by itself to push the emails to the outlook server in Rackspace directly.

This issue has some pointers; first I need to allow access for apps in the exchange server config, and then use the in the nodemailer transporter.

Follow the Microsoft article for authenticating web apps against the exchange server. This OAuth article is more specific.

ogallagher commented 4 years ago

Follow this answer for how to send mail through microsoft graph.

ogallagher commented 4 years ago

After nearly a whole day of laboring and searching and failing at sending an automated email through the Rackspace-hosted office365 email, I tried switching to Gsuite, following this tutorial from Medium. IT’S WORKING!

Now, I’m not sure whether the current nodemailer config might fail long-term (not really sure if it’s managing the smtp connections well, or if they’ll expire, for example) but I’m prepared to fix that later if it’s an issue. For now, I’m going to clear out my Sendgrid and Rackspace accounts and stick with Gsuite, and consider this issue closed. : )

ogallagher commented 4 years ago

The final budget is $24/yr for the two custom domains at Rt 53, plus $72/yr (at $6/mo/user) for the Gsuite email server and connected apps (I’ll point both MX DNS entries for the two domains to the same Gsuite email). I believe the EC2 web server instance is currently free, as well as the load balancer it’s hiding behind.

The grand total is: $96/yr, which should be manageable.

EDIT: The EC2 instances are $0.01/hr, on demand. I believe that means I can leave configured instances turned off and they won’t incur any charges, which is convenient for quick up-scaling later.