OSError:[Errno 99]地址不可用-使用gmail smtp从django docker应用程序发送电子邮件
我试图从docker中的django应用程序发送电子邮件,但出现以下错误:OSError:[Errno 99]地址不可用-使用gmail smtp从django docker应用程序发送电子邮件,django,docker,email,smtp,postfix-mta,Django,Docker,Email,Smtp,Postfix Mta,我试图从docker中的django应用程序发送电子邮件,但出现以下错误: OSError at /accounts/mail/ [Errno 99] Address not available Request Method: GET Request URL: https://localhost:8000/accounts/mail/ Django Version: 2.2.5 Exception Type: OSError Exception Value: [Errno 99]
OSError at /accounts/mail/
[Errno 99] Address not available
Request Method: GET
Request URL: https://localhost:8000/accounts/mail/
Django Version: 2.2.5
Exception Type: OSError
Exception Value:
[Errno 99] Address not available
Web服务器日志:
web_1 | OSError: [Errno 99] Address not available
web_1 | [17/Sep/2019 19:21:35] "GET /accounts/mail/ HTTP/1.1" 500 108369
我的docker撰写文件的一部分
version: '3.3'
services:
web:
build: ./app
command: python manage.py runsslserver 0.0.0.0:8000
...
ports:
- 8000:8000
- 587:587
- 25:25
env_file: .envdev
...
postfix:
image: juanluisbaptiste/postfix:latest
expose:
- "25"
env_file:
- .envpostfix
restart: always
volumes:
- "/etc/localtime:/etc/localtime:ro"
...
Docker.env文件:
EMAIL_BACKEND=django.core.mail.backends.smtp.EmailBackend
EMAIL_USE_TLS=True
EMAIL_HOST=smtp.gmail.com
EMAIL_HOST_USER=***
EMAIL_HOST_PASSWORD=***
EMAIL_PORT=587
我的后缀设置:
SMTP_SERVER=smtp.gmail.com
SMTP_PORT=587
SMTP_USERNAME=***
SMTP_PASSWORD=***
SERVER_HOSTNAME=127.0.0.1
问题解决了
我在django设置中创建了邮件变量,而不是只保存在docker.env文件中