首页 > 代码库 > Django+jenkins+python+RESTful framework(基于方法的视图)(2) 转发邮件
Django+jenkins+python+RESTful framework(基于方法的视图)(2) 转发邮件
Send_Email.py
@api_view([‘POST‘])
def sendEmail(request):
data = http://www.mamicode.com/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) 转发邮件
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。