Django发送邮件在本地工作,但在服务器上它不发送邮件

时间:2017-08-29 13:10:17

标签: django apache email

我有一个正常工作的smpt邮件在localhost上工作但是当我把应用程序放在服务器上时它不发送邮件。我认为有一些配置问题。 我正在使用apace2 ubuntu服务器14.04,我已将我的项目放在/ var / www /文件夹中。我通过配置000-default.conf文件强制https连接

Settings.py

from kivy.app import App
from kivy.uix.widget import Widget


class PongGame(Widget):
    pass


class PongApp(App):
    def build(self):
        return PongGame()


if __name__ == '__main__':
    PongApp().run()

   #:kivy 1.8.

<PongGame>:    
    canvas:
        Rectangle:
            pos: self.center_x - 5, 0
            size: 10, self.height

    Label:
        font_size: 70  
        center_x: root.width / 4
        top: root.top - 50
        text: "0"

    Label:
        font_size: 70  
        center_x: root.width * 3 / 4
        top: root.top - 50
        text: "0"

apache_config文件:

TEMPLATE_DEBUG =False

SECRET_KEY = **key**

DEBUG = False

ALLOWED_HOSTS = [**allowed hosts**]

import os

BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))


INSTALLED_APPS = (
'index',
'aboutus',
'aboutus.team',
'aboutus.careers',
'aboutus.locations',
'aboutus.board',    
'domainsec',
'projects',
'downloads',
'contactus',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
)

MIDDLEWARE_CLASSES = (
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'django.middleware.security.SecurityMiddleware',
)

X_FRAME_OPTIONS = 'DENY'

ROOT_URLCONF = **urls**

TEMPLATES = [
    {
    'BACKEND': 'django.template.backends.django.DjangoTemplates',
    'DIRS': [],
    'APP_DIRS': True,
    'OPTIONS': {
        'context_processors': [
            'django.template.context_processors.debug',
            'django.template.context_processors.request',
            'django.contrib.auth.context_processors.auth',
            'django.contrib.messages.context_processors.messages',
        ],
    },
},
]

WSGI_APPLICATION = 'antef.wsgi.application'

# Email
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_HOST_USER = **emailid**
EMAIL_HOST_PASSWORD = **password**
EMAIL_PORT = 587
EMAIL_USE_TLS = True

1 个答案:

答案 0 :(得分:0)

Google正在使用unlock-captcha来允许电子邮件发送,所以我去了https://accounts.google.com/DisplayUnlockCaptcha,然后我尝试使用python manage.py shell发送邮件。然后,对设备进行身份验证。