def mail_config(request): title = u'邮箱配置' if request.method == 'POST': host = request.POST.get('email_host') port = request.POST.get('email_port') user = request.POST.get('email_user') password = request.POST.get('email_password') use_tls = request.POST.get('email_use_tls', 'off') inputs = {'host':host,'port':port,'user':user,'password':password,'use_tls': 1 if use_tls=='on' else 0 } utils.set_email_info(inputs) from django.contrib import messages messages.add_message(request, messages.INFO, u'邮箱配置信息已保存成功!') return redirect(request.path) email = utils.get_email_info() return render(request, 'admin/mail_config.html', locals())
def mail_config(request): title = u'邮箱配置' if request.method == 'POST': host = request.POST.get('email_host') port = request.POST.get('email_port') user = request.POST.get('email_user') password = request.POST.get('email_password') use_tls = request.POST.get('email_use_tls', 'off') inputs = { 'host': host, 'port': port, 'user': user, 'password': password, 'use_tls': 1 if use_tls == 'on' else 0 } utils.set_email_info(inputs) from django.contrib import messages messages.add_message(request, messages.INFO, u'邮箱配置信息已保存成功!') return redirect(request.path) email = utils.get_email_info() return render(request, 'admin/mail_config.html', locals())
os.path.abspath(os.path.join(PROJECT_DIR, '../templates')), ) INSTALLED_APPS = ( 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'django.contrib.messages', 'django.contrib.staticfiles', 'django.contrib.admin', 'centre', 'tinymce', ) from centre import utils _email = utils.get_email_info() EMAIL_HOST = _email['host'] EMAIL_PORT = _email['port'] EMAIL_HOST_USER = _email['user'] EMAIL_HOST_PASSWORD = utils.decrypt(_email['password']) EMAIL_USE_TLS = bool(_email['use_tls']) # EMAIL_HOST = 'smtp.qq.com' # EMAIL_PORT = 587 # EMAIL_HOST_USER = '******' # EMAIL_HOST_PASSWORD = '******' # EMAIL_USE_TLS = True # EMAIL_HOST = 'smtp.163.com' # EMAIL_PORT = 25
INSTALLED_APPS = ( 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'django.contrib.messages', 'django.contrib.staticfiles', 'django.contrib.admin', 'centre', 'tinymce', ) from centre import utils _email = utils.get_email_info() EMAIL_HOST = _email['host'] EMAIL_PORT = _email['port'] EMAIL_HOST_USER = _email['user'] EMAIL_HOST_PASSWORD = utils.decrypt(_email['password']) EMAIL_USE_TLS = bool(_email['use_tls']) # EMAIL_HOST = 'smtp.qq.com' # EMAIL_PORT = 587 # EMAIL_HOST_USER = '******' # EMAIL_HOST_PASSWORD = '******' # EMAIL_USE_TLS = True # EMAIL_HOST = 'smtp.163.com' # EMAIL_PORT = 25