Django+jenkins+python+RESTful framework(3) 转发邮件

Django的设置:

project 下的settings.py 文件中加入以下配置信息:

EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_USE_TLS = False
EMAIL_HOST = 'xx'
EMAIL_PORT = 25
EMAIL_HOST_USER = ''
EMAIL_HOST_PASSWORD = ''
DEFAULT_FROM_EMAIL = 'xx'


url.py 的文件中加入
urlpatterns = [
url(r'^sendmail/$', send_emails.sendEmail,name='sendMails'),
]
完整代码:
"""SendMail URL Configuration

The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/1.8/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: url(r'^$', views.home, name='home')
Class-based views
1. Add an import: from other_app.views import Home
2. Add a URL to urlpatterns: url(r'^$', Home.as_view(), name='home')
Including another URLconf
1. Add an import: from blog import urls as blog_urls
2. Add a URL to urlpatterns: url(r'^blog/', include(blog_urls))
"""
from django.conf.urls import include, url
from django.contrib import admin
from testEmail.test import Send_Email

urlpatterns = [
url(r'^sendmail/$', send_emails.sendEmail,name='sendMails'),
url(r'^admin/', include(admin.site.urls)),
]
 
posted @ 2017-06-28 13:23  PyJava老鸟  阅读(428)  评论(0编辑  收藏  举报