Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to Send Emails Using Flask-Mail with Mailtrap SMTP Server #118

Open
synetalsolutions opened this issue Feb 12, 2024 · 0 comments
Open

Comments

@synetalsolutions
Copy link

Description:
I am encountering an error when attempting to send emails using Flask-Mail with Mailtrap SMTP server configured in Docker-compose.yml. The error message indicates a problem with the sender address syntax.

Traceback (most recent call last): File "/usr/lib/python3.8/threading.py", line 932, in _bootstrap_inner self.run() File "/usr/lib/python3.8/threading.py", line 870, in run self._target(*self._args, **self._kwargs) File "/app/app/email.py", line 8, in send_async_email mail.send(msg) File "/usr/local/lib/python3.8/dist-packages/flask_mail.py", line 492, in send message.send(connection) File "/usr/local/lib/python3.8/dist-packages/flask_mail.py", line 427, in send connection.send(self) File "/usr/local/lib/python3.8/dist-packages/flask_mail.py", line 188, in send self.host.sendmail(sanitize_address(envelope_from or message.sender), File "/usr/lib/python3.8/smtplib.py", line 880, in sendmail raise SMTPSenderRefused(code, resp, from_addr) smtplib.SMTPSenderRefused: (501, b'5.1.7 Bad sender address syntax', 'api')

Steps to Reproduce:

  1. Configure Mailtrap SMTP server in Docker-compose.yml.
  2. Use Flask-Mail to send emails in your application.
  3. Trigger an email sending action.

Expected Behavior:

Emails should be sent successfully through the configured Mailtrap SMTP server without any syntax issues.

Actual Behavior:
Encountering a syntax issue with the sender address, leading to the failure of email sending.

Additional Information:

Flask-Mail version: [Insert Flask-Mail version]
Python version: [Insert Python version]
Docker-compose.yml configuration for Mailtrap SMTP server.

Note:
I have ensured that the sender address is correctly formatted, and I've tested the SMTP server configuration outside of Flask-Mail, which works fine. This issue seems specific to Flask-Mail interaction with Mailtrap.

Any insights or suggestions on resolving this issue would be greatly appreciated.

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

No branches or pull requests

1 participant