Skip to content
This repository has been archived by the owner on Nov 17, 2021. It is now read-only.

Support STARTTLS (port 25) #19

Closed
dfrankow opened this issue Apr 23, 2020 · 11 comments
Closed

Support STARTTLS (port 25) #19

dfrankow opened this issue Apr 23, 2020 · 11 comments
Labels

Comments

@dfrankow
Copy link

As documented in #18, my ISP blocks port 25. Similarly, Amazon also blocks port 25 by default.

When I try port smtp.gmail.com:587, it wants TLS:

09:36:19.037743 send: 'helo smtp.gmail.com\r\n'
09:36:19.089443 reply: b'250 smtp.gmail.com at your service\r\n'
09:36:19.089573 reply: retcode (250); Msg: b'smtp.gmail.com at your service'
09:36:19.089910 send: 'mail FROM:<valid.email@example.com>\r\n'
09:36:19.137085 reply: b'530 5.7.0 Must issue a STARTTLS command first. h19sm1787816qtk.78 - gsmtp\r\n'
...

It might be useful to support TLS if it were easy, though I don't know enough to say for sure.

@karolyi
Copy link
Owner

karolyi commented Apr 23, 2020

Port 587 is not an SMTP port, it's just SMTP-ish.

That said, TLS support might be worth it, but as the current state of internet, 25 should suffice. If your ISP blocks it, you might want to inquire as to why they do it.

@karolyi
Copy link
Owner

karolyi commented Apr 23, 2020

Also note in the case of Amazon, throttle != block. Throttling it makes more sense to me, to avoid spam from EC2 instances.

Moreover, a proper authenticated sender can still use EC2 instances to send emails, see the same document you linked.

What are you trying to use this module for?

@dfrankow
Copy link
Author

My ISP blocks it for the same reason as everyone else: "In order to help protect against spam".

In the case of Amazon, I did not realize it's a throttle, because the behavior I see looks like a block. By "proper authenticated sender", I think you mean I could file a support ticket and try to convince them.

An alternative to filing support tickets with Amazon is a library that works with port 587, which is why I filed this feature request. You can accept my request or not, as you choose.

I am trying to use this module to validate a few hundred email addresses in a research project. Emails validated thus far: zero. Also, I may have to repeat the process, so it seemed worth trying to get it to work systematically. However, I may have to try other routes, like getting unblocked friends to run my script or using a paid validation service.

@karolyi
Copy link
Owner

karolyi commented Apr 23, 2020

Again, port 587 won't work for address validation, as it's for submission, not for inbound SMTP. It speaks SMTP but won't do validation normally, at least it's not its job. Hence SMTP-ish, but not SMTP. Most likely all responses will be denied with "relay access denied without authorization". With submission, you have to authorize yourself as a sender, that happens with TLS using SASL.

I use this project in a couple of my projects to check emails at registration time, so not hundreds at a time. Doing so can make you (or your server's IP) end up in various blocklists. I told this to other users as well: this is is a tool, but every tool can become a weapon if you use it the wrong way.

One more thing: SMTP servers that use blocklists (such as mine) will block your IP, even if you get unblocked by your ISP. ISP IP pools are in blocklists for the most part, exactly because why your ISP blocks port 25: blocking spam from botnets (malware infected PCs) used by spammers.

The takeaway here is, SSL support (STARTTLS on port 25 or SSL on port 465 with SMTP_SSL) could be added as functionality, but unencrypted port 25 should normally suffice.

@dfrankow
Copy link
Author

Thanks for the information, very helpful. I leave it to you whether to resolve this or not.

@karolyi karolyi changed the title Support TLS on port 587 Support STARTTLS (port 25) and/or SSL (port 465) Apr 24, 2020
@karolyi karolyi added the enhancement New feature or request label Jun 11, 2020
@hack3r-0m
Copy link

As per RFC 8314, implicit TLS is recommended rather than explicit TLS on 587. can I try to add support for port 465? and what challenges I might face for this? Thanks

@karolyi
Copy link
Owner

karolyi commented Jun 17, 2020

Again, port 587 is submission, as in outbound emails. It's not used for checking email addresses that the host has. Port 465 is defined as smtps, but is used as an implicit TLS version of the port 586 with which you have to use STARTTLS.

Let's clarify this once and for all: none of these two ports are used for inbound emails, normally.

You can try to implement a STARTTLS with port 25. The smtplib library has a starttls method, that might be useful. but be prepared to fall back to cleartext if the remote server doesn't support it. Submit a PR and I'll look into it.

@karolyi karolyi changed the title Support STARTTLS (port 25) and/or SSL (port 465) Support STARTTLS (port 25) Jun 17, 2020
@hack3r-0m
Copy link

@karolyi starttls should only be viable if valid MX records exist in order to check whether MX accepts mail or not right?

@karolyi
Copy link
Owner

karolyi commented Jul 10, 2020

no, not really.

any host that will be probed might or might not support STARTTLS. the protocol being negotiated is completely different from the DNS records resolving.

@karolyi
Copy link
Owner

karolyi commented Oct 11, 2020

This should work now in 0.2.10, please update and let me know if it works for you.

@karolyi karolyi removed the enhancement New feature or request label Oct 11, 2020
@stale
Copy link

stale bot commented Oct 25, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants