background

Originally feel configuration mail is a simple work, there are corresponding information on the Internet can refer to, did not plan to write. However, I encountered quite a few hicks in configuring email notifications, so I felt I needed to keep track of them to save other people some time.

Problems encountered:

SMTPAuthenticationError

SMTPAuthenticationError: (535, 'Error: \xc7\xeb\xca\xb9\xd3\xc3\xca\xda\xc8\xa8\xc2\xeb\xb5\xc7\xc2\xbc\xa1\xa3\xcf\xea\xc7\xe9\xc7\xeb\xbf\xb4: http://service.mail.qq.com/cgi-bin/help?subtype=1&&id=28&&no=1001256')

Copy the code

There are two reasons for the problem:

  1. STMP service is not enabled for QQ mailbox
  2. The STMP address is incorrect

You can write your own demo and test it

// .test.py
#coding: utf-8  
import smtplib
from email.mime.text import MIMEText
from email.header import Header
sender = '[email protected]'
receiver = '[email protected]'
subject = 'python email test'
smtpserver = 'smtp.qq.com'
username = '[email protected]'
password = '* * * * * * * * * * * *'
msg = MIMEText( 'Hello Python'.'text'.'utf-8' )
msg['Subject'] = Header( subject, 'utf-8' )
smtp = smtplib.SMTP()
smtp.connect( smtpserver )
smtp.login( username, password )
smtp.sendmail( sender, receiver, msg.as_string() )
smtp.quit()

Copy the code
python test.py
Copy the code

If the email cannot be sent, check the STMP address and whether the STMP service is enabled

The configuration file address is./sentry/config.yml

# **** omit a bunch
mail.backend: 'smtp'  # Use dummy if you want to disable email entirely
mail.host: 'smtp.qq.com'
mail.port: 25
mail.username: '[email protected]'
mail.password: '* * * * * * * *'
mail.use-tls: false
# The email address to send on behalf of
mail.from: '[email protected]'
# Note: host is the service address of STMP, qq is the other need to find it by yourself
# I found a stmp.exmail.qq.com online before this is invalid
Port 25 TLS false Port 587 TLS true
# The password here corresponds to the authorization code generated in the figure above
Copy the code

This is a read-only file and it’s best to copy it, change it and then overwrite it and build it again

sudo cp ./sentry/my.config.yml ./sentry/config.yml 
sudo docker-compose build
sudo docker-compose run --rm web upgrade
sudo docker-compose up -d 
Copy the code

SMTPException

SMTP AUTH extension not supported by server.