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

smtplib.SMTPRecipientsRefused: (550, b'relay not permitted') #77

Open
paso0129 opened this issue Jan 28, 2021 · 2 comments
Open

smtplib.SMTPRecipientsRefused: (550, b'relay not permitted') #77

paso0129 opened this issue Jan 28, 2021 · 2 comments

Comments

@paso0129
Copy link

Hello I am simply trying to send mail using smtplib.

I added the certificate to the smtp container, and when I ran that code, this '550, b'relay not permitted' occurred. It seems that it cannot be received from other receiving servers.

Please help.
Thank you.

import mail
from flask import Flask, request, Response, jsonify
import smtplib

app = Flask(__name__)


@app.route("/sendMail", methods=['POST'])
def sendMail():
    data = request.get_json()
    print(data)

    from_email = data.get('from email')
    to_email = data.get('to email')
    subject = data.get('subject')
    contents = data.get('contents')

    sender = from_email
    receiver = to_email
    msg = '''\
... From: [email protected]
... Subject: testin'...
...
... This is a test '''

    smtpObj = smtplib.SMTP('mail.kfems.org', 25)
    smtpObj.sendmail(sender, receiver, msg)

    return jsonify(data)

if __name__ == '__main__':
    app.run(host='0.0.0.0', debug=True, port=5050)
@tpai
Copy link

tpai commented Jan 29, 2021

I running into the same situation right now, it worked couple days ago, wondering what happened to the Gmail service.

Update

My bad, I have a check inside the container, and see my username and password mess up password.client as below:

*.gmail.com:<username>
:<password>

Looks like my credentials did not escape newline, SMTP works normal after resolve this.

@tpai
Copy link

tpai commented Jan 30, 2021

Hi @paso0129

Please make sure RELAY_NETWORKS is well-defined.

If you don't define it, SMTP container will reject all the mail requests except 10.2.0.2/32 which is itself.

For internal network, I will recommend to use RELAY_NETWORKS=:10.0.0.0/8:127.0.0.0/8:172.17.0.0/16:192.0.0.0/8 .

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

2 participants