Using Django to send emails with AWS with a reverse DNS setup to point at a different server
Asked Answered
K

1

6

I'm trying to setup Django on an AWS instance to send emails through my main website's server (non-AWS) rather than needing to use external mail services such as Mandrill, Amazon SES... etc

I first setup my main server's DNS records to point a sub-domain to the aws instance's elastic IP, for example:

mail1.website.com --> 1.1.1.1

I filed a request to have a reverse DNS record setup pointing my AWS instance's elastic IP to a sub-domain, they set it up for example:

1.1.1.1 --> mail1.website.com

Now that the reverse dns record is setup mail1.website.com should be able to be used in django to send emails without them being marked as spam.

https://docs.djangoproject.com/es/1.9/topics/email/#smtp-backend

Would using the following be enough?

EMAIL_HOST = 'mail1.website.com'
DEFAULT_FROM_EMAIL = 'test.website.com'

If I need to provide email user/password/port is it possible to set it up to login with a specific email like [email protected] but then email from [email protected] or do I have to setup the smtp settings to the root email address

No_reply email:

EMAIL_HOST = 'mail1.website.com'
EMAIL_HOST_USER = '[email protected]'
EMAIL_HOST_PASSWORD = 'mypasshere'
EMAIL_PORT = 465
DEFAULT_FROM_EMAIL = 'test.website.com'

or root:

EMAIL_HOST = 'mail1.website.com'
EMAIL_HOST_USER = 'root'
EMAIL_HOST_PASSWORD = 'mypasshere'
EMAIL_PORT = 465
DEFAULT_FROM_EMAIL = '[email protected]'
Kelwin answered 27/4, 2016 at 22:40 Comment(3)
Not too sure what you are asking here. Reverse DNS doesn't have much to do with how you send email. As for whether you need a username/password that depends on whether you are using your local machine's SMTP server (if so, then no authentication is required) or some third party one which requires authentication.Denier
@Ryflex: "Would using the following be enough?" Enough for what exactly? Can you clarify please? Are you concerned about rDns? Spam scoring? Reply-to: headers? Or django configuration?Ringent
"Enough" to be correct, so that rDNS doesn't cause emails to be marked as spam, mainly to fix: SPF_SOFTFAIL, RDNS_DYNAMIC and HELO_DYNAMIC_IPADDR. I've already got a reverse dns setup as explained aws.amazon.com/blogs/aws/… by using aws.amazon.com/forms/ec2-email-limit-rdns-requestKelwin
W
1

I'm not sure I understand why you're trying to do this, but if your current email server is operating correctly, and you want to be able to use it to relay emails from your AWS instance, I would simply set up a VPN between AWS and your current network, and allow your AWS instance to send email that way. You're not using your email server as an external relay, so deliverability shouldn't change.

But really, the correct answer is to use SES to send emails. As long as you're not doing anything abusive, you should have no problems with deliverability.

Edit: The specific exceptions you mention (SPF_SOFTFAIL, RDNS_DYNAMIC and HELO_DYNAMIC_IPADDR) may not go away even if you set up reverse DNS for your AWS instance public IP - you are still drawing from a pool of known "dynamic" IP addresses - AWS publishes their list of IP addresses here - and I doubt may people bother to check to see if some small number of those is set up properly.

Setting up SPF to allow AWS to send on your behalf is pretty easy.

Wellthoughtof answered 4/5, 2016 at 21:5 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.