0
내가 인해 메일 서버 문제로 가끔 파이썬 플라스크 mail.send 오류 검사 및 로그가
if app.config['MAIL']:
mail.send(message)
else:
print message.html
같은 메일 코드 부분 플라스크 응용 프로그램을 가지고는 mail.send() 함수가 실패합니다. 오류 상태 을 확인하고 어떻게 로그합니까?
if app.config['MAIL']:
try:
mail.send(message)
except SMTPException, e:
current_app.logger.error(e.message)
else:
print message.html
당신은 SMTPException
에 따라 많은 예외를 찾을 수 있습니다 :
에서는 예외가 잡으려고
if app.config['MAIL']:
retcode=mail.send(message)
else:
print message.html
# now log it
if (retcode != 0):
#log it or take anyother action.
감사합니다! –