Issue sending email from my Linode IP

I have set up a basic web app that allows users to create accounts & track data. There is functionality that allows a user to reset their password, and this did work when I was hosting the app on my local machine. I'm using Flask Mail, and the whole program is running in a VM (Python venv). When I try to send the message from my domain (I've pinpointed the line in the code where it stalls: mail.send(msg)) the next page never loads, the email is never sent, and the connection times out.

I am trying to sort out if this is related to the ufw I have set up, though I did configure it to allow all outgoing packets:
$sudo ufw default allow outgoing
$sudo ufw enable
I am using 'smtp.gmail.com' as the mail server with TLS, and had no issue with this running on my local machine.

Any ideas as to why this might not be working and how to fix it would be appreciated, thank you!

3 Replies

Here is the output log. I have replaced my username with 'ME'.

DEBUG |send_reset_email()| right before mail.send(msg)
[2020-12-25 16:45:05,509] ERROR in app: Exception on /reset_password [POST]
Traceback (most recent call last):
File "/home/ME/venv/lib/python3.8/site-packages/flask/app.py", line 2447, in wsgi_app
response = self.full_dispatch_request()
File "/home/ME/venv/lib/python3.8/site-packages/flask/app.py", line 1952, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/home/ME/venv/lib/python3.8/site-packages/flask/app.py", line 1821, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/home/ME/venv/lib/python3.8/site-packages/flask/compat.py", line 39, in reraise raise value File "/home/ME/venv/lib/python3.8/site-packages/flask/app.py", line 1950, in full_dispatch_request rv = self.dispatch_request() File "/home/ME/venv/lib/python3.8/site-packages/flask/app.py", line 1936, in dispatch_request return self.view_functionsrule.endpoint File "/home/ME/users/routes.py", line 81, in reset_request send_reset_email(user) File "/home/ME/users/utils.py", line 20, in send_reset_email mail.send(msg) File "/home/ME/venv/lib/python3.8/site-packages/flask_mail.py", line 491, in send with self.connect() as connection: File "/home/ME/venv/lib/python3.8/site-packages/flask_mail.py", line 144, in enter_
self.host = self.configure_host()
File "/home/ME/venv/lib/python3.8/site-packages/flask_mail.py", line 158, in configure_host
host = smtplib.SMTP(self.mail.server, self.mail.port)
File "/usr/lib/python3.8/smtplib.py", line 253, in __init

(code, msg) = self.connect(host, port)
File "/usr/lib/python3.8/smtplib.py", line 339, in connect
self.sock = self._get_socket(host, port, self.timeout)
File "/usr/lib/python3.8/smtplib.py", line 308, in _get_socket
return socket.create_connection((host, port), timeout,
File "/usr/lib/python3.8/socket.py", line 808, in create_connection
raise err
File "/usr/lib/python3.8/socket.py", line 796, in create_connection
sock.connect(sa)
TimeoutError: [Errno 110] Connection timed out

@honeybadgerofdoom --

I can't speak to all the Python gobbledegook but the reason you can't send email is probably because all the email ports (25, 465, 587) are blocked by default. See:

https://www.linode.com/community/questions/19082/i-just-created-my-first-linode-and-i-cant-send-emails-why

-- sw

That looks like the solution, thank you!

Matt

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct