ENH: Connection failures should not be misleading and say "please run connect() first"
metaperl opened this issue · 1 comments
Is your feature request related to a problem? Please describe.
When the connection fails, one receives the misleading exception: "please run connect() first" which is coming from red-mail calling smtplib.
Describe the solution you'd like
Provide an accurate and descriptive feedback that connection failed.
We ran the simplest red-mail script possible:
from redmail import EmailSender
from smtplib import SMTP
email = EmailSender(
host="false-host",
port=25
)
and got a totally misleading error message: "please run connect() first" instead of being told the connection failed.
Once we switched host to localhost
the script ran fine.
A little more detail on this: this cryptic error message only occurs in our work environment where there are proxies that block access to certain domains.
At home, I get a descriptive error message for the following program:
from redmail import EmailSender
email = EmailSender(
host='fakedomain.livingcosmos.org',
port=25
)
def main():
email.send(
subject='email subject',
sender="me@example.com",
receivers=['you@example.com'],
text="Hi, this is an email."
)
# Press the green button in the gutter to run the script.
if __name__ == '__main__':
main()