• Django+jenkins+python+RESTful framework(基于Class的视图)(4) 转发邮件


    Send_Email.py
    class SendEmailViewList(BaseViewList):
    def __init__(self):
    super(SendEmailViewList, self).__init__(None)
    def post(self, request, format=None):
    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)


    @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)
  • 相关阅读:
    HDU 4619 Warm up 2 (多校)
    深入浅出Node.js (9)
    HDU 1106 排序(排序)
    字符串相关心得
    HDU 2547 无剑无我(数学)
    HDU 2549 壮志难酬(字符串,处理小数点)
    HDU 2551 竹青遍野(循环,水)
    HDU 2552 三足鼎立(数学函数)
    HDU 2555 陷阱(模拟,结构体数组)
    HDU 2561 第二小整数(排序,水)
  • 原文地址:https://www.cnblogs.com/QAZLIU/p/5748230.html
Copyright © 2020-2023  润新知