码迷,mamicode.com
首页 > 编程语言 > 详细

Django+jenkins+python+RESTful framework(基于方法的视图)(2) 转发邮件

时间:2017-06-28 14:30:46      阅读:136      评论:0      收藏:0      [点我收藏+]

标签:style   send   ret   framework   from   tla   work   pre   color   

Send_Email.py



@api_view([‘POST‘])
def sendEmail(request):
data = getRequestBody(request)
print type(data)
emailServer = data.get(‘emailServer‘)
user = data.get(‘fromUser‘)
passwd = data.get(‘frompasswd‘)
recipients = data.get(‘toRecipients‘)
startSendEmail(emailServer,user,passwd,*recipients)
return Response({‘result‘:‘Have send Emails‘},status=200)

def startSendEmail(emailServer,fromUser,frompasswd,*toRecipients):
from django.conf import settings
settings.EMAIL_HOST_USER = fromUser
settings.EMAIL_HOST_PASSWORD = frompasswd
server = FetchMail(emailServer, fromUser, frompasswd)
content = server.getLatestEmailContent()
detailsContent = server.getDetailsContent(content)
subject = server.getSubject(content)
address = server.getAddress(content)
send_mail(subject, detailsContent, address, toRecipients, html_message=detailsContent)

Django+jenkins+python+RESTful framework(基于方法的视图)(2) 转发邮件

标签:style   send   ret   framework   from   tla   work   pre   color   

原文地址:http://www.cnblogs.com/QAZLIU/p/5748185.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!