当前位置: 首页>>代码示例>>Python>>正文


Python COMMASPACE.join方法代码示例

本文整理汇总了Python中email.Utils.COMMASPACE.join方法的典型用法代码示例。如果您正苦于以下问题:Python COMMASPACE.join方法的具体用法?Python COMMASPACE.join怎么用?Python COMMASPACE.join使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在email.Utils.COMMASPACE的用法示例。


在下文中一共展示了COMMASPACE.join方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: send_mail

# 需要导入模块: from email.Utils import COMMASPACE [as 别名]
# 或者: from email.Utils.COMMASPACE import join [as 别名]
def	send_mail( send_from, send_to, subject, text, cc, \
		bcc, attachments, server, login, passwd ) :

	assert type( send_to )==list
	assert type( attachments )==list
	assert type( cc )==list
	assert type( bcc )==list

	msg = MIMEMultipart()
	msg['From'] = send_from
	msg['To'] = COMMASPACE.join( send_to )
	#msg['To'] = send_to[0]
	msg['CC'] = COMMASPACE.join( cc )
	#msg['CC'] = cc[0]
	msg['BCC'] = COMMASPACE.join( bcc )
	#msg['BCC'] = bcc[0]
	msg['Date'] = formatdate( localtime=True )
	msg['Subject'] = subject

	msg.attach( MIMEText( text ) )

	for f in attachments :
		part = MIMEBase( 'application', "octet-stream" )
		part.set_payload( open( f, "rb" ).read() )
		Encoders.encode_base64( part )
		part.add_header( 'Content-Disposition', 'attachment; filename="%s"' % 
			os.path.basename( f ))
		msg.attach( part )

	server = smtplib.SMTP( server )
	if login :
		server.login( login, passwd )
	server.sendmail( send_from, send_to, msg.as_string() )
	server.close()
开发者ID:AlRasheed,项目名称:CS265,代码行数:36,代码来源:pmail.py

示例2: sendMailOnChanges

# 需要导入模块: from email.Utils import COMMASPACE [as 别名]
# 或者: from email.Utils.COMMASPACE import join [as 别名]
    def sendMailOnChanges(self, messageText, emailSubject, org_message_ID, new_message_ID, username=False, diff_HN_adress=None, **kwargs):
        msg = MIMEMultipart()
        reply_to = []
        send_to = []
        if org_message_ID != None:
            msg['In-Reply-To'] = org_message_ID
            msg['References'] = org_message_ID

        #send_from = "[email protected]"
        send_from = getUserEmail(username, Session)
        msg['From'] = send_from
        if diff_HN_adress == None:
            send_to += [self.MAILING_LIST[0]]
        else:
            send_to += [diff_HN_adress]
        #if username != False:   #send email copy to the sender himself
        #    email = getUserEmail(username, Session)
        #    send_to.append(email)
        reply_to.append(send_from) #make a reply header to sender+receivers of the email.
        reply_to.append("[email protected]")
        msg['reply-to'] = COMMASPACE.join(reply_to)
        msg['To'] = COMMASPACE.join(send_to)
        msg['Date'] = formatdate(localtime=True)
        msg['Subject'] = emailSubject
        msg['Message-ID'] = new_message_ID

        try:
            msg.attach(MIMEText(messageText))
            smtpObj = smtplib.SMTP()
            smtpObj.connect()
            smtpObj.sendmail(send_from, send_to, msg.as_string())
            smtpObj.close()         
        except Exception as e:
            logging.error("Error: unable to send email: %s", str(e))
开发者ID:RREYESAL,项目名称:RPC_HVScan,代码行数:36,代码来源:ajax_app.py

示例3: send_mail

# 需要导入模块: from email.Utils import COMMASPACE [as 别名]
# 或者: from email.Utils.COMMASPACE import join [as 别名]
def send_mail(subject, message, server="localhost"):

    sender = "[email protected]"
    to = ['[email protected]']
    cc = []

    msg = MIMEMultipart()
    msg['From'] = sender
    msg['To'] = COMMASPACE.join(to)
    msg['Date'] = formatdate(localtime=True)
    msg['Subject'] = subject
    msg['Cc'] = COMMASPACE.join(cc)
    msg.attach(MIMEText(message))

    addresses = []
    for x in to:
        addresses.append(x)
    for x in cc:
        addresses.append(x)

    try:
        smtp = smtplib.SMTP(server)
        smtp.sendmail(sender, addresses, msg.as_string())
        smtp.close()
        log.info("Mail Sent Successfully")
    except smtplib.SMTPException as e:
        log.error("%s", traceback.format_exc())
开发者ID:harsh-grover,项目名称:myFirstRepo,代码行数:29,代码来源:utils.py

示例4: send

# 需要导入模块: from email.Utils import COMMASPACE [as 别名]
# 或者: from email.Utils.COMMASPACE import join [as 别名]
    def send(self, to, subject, body, cc=None, attachs=(), mimetype='text/plain',body_encode='utf8'):
        if attachs:
            msg = MIMEMultipart()
        else:
            msg = MIMENonMultipart(*mimetype.split('/', 1))
        msg['From'] = self.mailfrom
        msg['To'] = COMMASPACE.join(to)
        msg['Date'] = formatdate(localtime=True)
        msg['Subject'] = subject
        rcpts = to[:]
        if cc:
            rcpts.extend(cc)
            msg['Cc'] = COMMASPACE.join(cc)

        if attachs:
            msg.attach(MIMEText(body, 'plain', body_encode))
            for attach_name, mimetype, f in attachs:
                part = MIMEBase(*mimetype.split('/'))
                part.set_payload(f.read())
                Encoders.encode_base64(part)
                part.add_header('Content-Disposition', 'attachment; filename="%s"' \
                    % attach_name)
                msg.attach(part)
        else:
            msg.set_payload(body)

        try:
            self._sendmail(rcpts, msg.as_string())
        except smtplib.SMTPException, e:
            self._sent_failed(e, to, cc, subject, len(attachs))
            return False
开发者ID:zzpwelkin,项目名称:autospider,代码行数:33,代码来源:mail.py

示例5: sendmail

# 需要导入模块: from email.Utils import COMMASPACE [as 别名]
# 或者: from email.Utils.COMMASPACE import join [as 别名]
def sendmail(subject, message, sender='[email protected]', to=[], cc=[], 
                bcc=[], attachments=[], priority=3, type_="plain", 
                smtp_server="smtp.eecs.umich.edu"):
    assert priority in range(1,6)
    
    msg = MIMEMultipart()
    msg['From'] = sender
    msg['To'] = COMMASPACE.join(to)
    msg['Cc'] = COMMASPACE.join(cc)
    msg['X-Priority'] = str(priority)
    msg['Date'] = formatdate(localtime=True)
    msg['Subject'] = subject
    msg.attach(MIMEText(message, type_)) 

    for f in attachments:
        part = MIMEBase('application', "octet-stream")
        part.set_payload(open(f,"rb").read()) 
        Encoders.encode_base64(part)
        part.add_header('Content-Disposition', 'attachment; filename="%s"'\
                        % os.path.basename(f))
        msg.attach(part)

    to.extend(cc)
    to.extend(bcc)
    smtp = smtplib.SMTP(smtp_server)
    smtp.sendmail(sender, to, msg.as_string())
    smtp.close()
开发者ID:g11tch,项目名称:netutil,代码行数:29,代码来源:mail.py

示例6: send_mail

# 需要导入模块: from email.Utils import COMMASPACE [as 别名]
# 或者: from email.Utils.COMMASPACE import join [as 别名]
def send_mail(send_from, send_to,send_cc, subject, text, files=[],server="localhost"):    
    assert type(send_to)==list    
    assert type(files)==list

    msg = MIMEMultipart('alternative')
    msg['From'] = send_from
    msg['To'] = COMMASPACE.join(send_to)
    
    if send_cc is None:
        send_tocc = send_to
    else:
        assert type(send_cc)==list
        msg['Cc'] = COMMASPACE.join(send_cc)
        send_tocc = send_to + send_cc
        
    msg['Date'] = formatdate(localtime=True)
    msg['Subject'] = subject

    msg.attach( MIMEText(text) )

    for f in files:
        part = MIMEBase('application', "octet-stream")
        part.set_payload( open(f,"rb").read() )
        Encoders.encode_base64(part)
        part.add_header('Content-Disposition', 'attachment; filename="%s"' % os.path.basename(f))
        msg.attach(part)
    
    smtp = smtplib.SMTP(server)
    smtp.sendmail(send_from, send_tocc, msg.as_string())
    smtp.close()
开发者ID:wkoay87,项目名称:Sample_Scripts,代码行数:32,代码来源:send_email.py

示例7: send_email

# 需要导入模块: from email.Utils import COMMASPACE [as 别名]
# 或者: from email.Utils.COMMASPACE import join [as 别名]
def send_email(to, subject, text, user_from, files=[], cc=[], bcc=[],
        server=EMAIL_SERVER, port = EMAIL_PORT, user = EMAIL_USER,
        password = EMAIL_PASS, domain = EMAIL_DOMAIN):

    message = MIMEMultipart()
    message['From'] = user_from
    message['To'] = COMMASPACE.join(to)
    message['Date'] = formatdate(localtime=True)
    message['Subject'] = subject
    message['Cc'] = COMMASPACE.join(cc)
    message.attach(MIMEText(text))

    for f in files:
        part = MIMEBase('application', 'octet-stream')
        part.set_payload(f)
        part.add_header('Content-Disposition', 'attachment; filename="%s"' % \
        'report.csv')
        message.attach(part)

    addresses = []
    for x in to:
        addresses.append(x)
    for x in cc:
        addresses.append(x)
    for x in bcc:
        addresses.append(x)

    s = smtplib.SMTP_SSL(server, port, domain)
    s.login(user, password)

    s.sendmail(user_from, addresses, message.as_string())
开发者ID:davinirjr,项目名称:cron-metrics,代码行数:33,代码来源:send_email.py

示例8: sendMailWithAttachements

# 需要导入模块: from email.Utils import COMMASPACE [as 别名]
# 或者: from email.Utils.COMMASPACE import join [as 别名]
def sendMailWithAttachements(context, sender, receiver, cc=[], bcc=[], subject="", text="", files=[]):
    """
    """
    mail = MIMEMultipart()
    
    mail['From'] = sender
    mail['To']  = receiver
    mail['Cc'] = COMMASPACE.join(cc)
    mail['Bcc'] = COMMASPACE.join(bcc)        
    mail['Subject'] = subject
    
    # text = text.encode("utf-8")
    # text_part = MIMEText(text, "plain", "utf-8")
    # mail.attach(text_part)

    # create & attach html part with images
    text = text.encode("utf-8")
    mail.attach(MIMEText(text, "html", "utf-8"))
    
    for filename, file_ in files:
        try:
            data = file_.data.data
        except AttributeError:
            data = file_.data
            
        attachment_part = MIMEBase('application', "octet-stream")
        attachment_part.set_payload(data)
        Encoders.encode_base64(attachment_part)
        attachment_part.add_header('Content-Disposition', 'attachment; filename=%s' % filename)
        mail.attach(attachment_part)
    
    context.MailHost.send(mail.as_string())
开发者ID:Easyshop,项目名称:Easyshop,代码行数:34,代码来源:misc.py

示例9: send_mail

# 需要导入模块: from email.Utils import COMMASPACE [as 别名]
# 或者: from email.Utils.COMMASPACE import join [as 别名]
def send_mail(send_to, subject, text, files=[], cc=[]):
    assert isinstance(send_to, list)
    assert isinstance(files, list)
    assert isinstance(cc, list)

    msg = MIMEMultipart()
    msg['From'] = sender_username
    msg['To'] = COMMASPACE.join(send_to)
    msg['Date'] = formatdate(localtime=True)
    msg['Subject'] = subject
    #new things...
    msg['CC'] = COMMASPACE.join(cc)
    send_to = send_to + cc

    msg.attach( MIMEText(text) )

    for f in files:
        print "Attaching %s..." % os.path.basename(f),
        part = MIMEBase('application', "octet-stream")
        part.set_payload( open(f,"rb").read() )
        Encoders.encode_base64(part)
        part.add_header('Content-Disposition', 'attachment; filename="%s"' % os.path.basename(f))
        msg.attach(part)

    print "Sending...",
    smtp = smtplib.SMTP('smtpout.secureserver.net', 80)
    smtp.login(sender_username, sender_pass)
    smtp.sendmail(sender_username, send_to, msg.as_string())
    smtp.close()
开发者ID:asharmalik,项目名称:EmailerLite,代码行数:31,代码来源:emailerlite.py

示例10: notifyWithBCC

# 需要导入模块: from email.Utils import COMMASPACE [as 别名]
# 或者: from email.Utils.COMMASPACE import join [as 别名]
def notifyWithBCC( receiver = ['email'],\
            cc = [''],\
            bcc = [''],\
            subject = 'generic subject',\
            body = 'generic body',\
            files=[],
            transmitter = 'email',
            server = '192.168.75.40'):
    header = "From: %s\r\nTo: %s\r\nSubject: %s\r\nX-Mailer: My-Mail\r\n\r\n" % (transmitter, receiver, subject)

    #msg = header + body

    msg = MIMEMultipart()
    msg['From'] = transmitter
    msg['To'] = COMMASPACE.join(receiver)
    msg['Cc'] = COMMASPACE.join(cc)
    msg['Date'] = formatdate(localtime=True)
    msg['Subject'] = subject

    msg.attach( MIMEText(body) )

    for f in files:
        part = MIMEBase('application', "octet-stream")
        part.set_payload( open(f,"rb").read() )
        Encoders.encode_base64(part)
        part.add_header('Content-Disposition', 'attachment; filename="%s"' % os.path.basename(f))
        msg.attach(part)

    server = smtplib.SMTP(server)
    server.set_debuglevel(0)
    server.sendmail(transmitter, receiver + cc + bcc, msg.as_string())
    server.quit()
开发者ID:Remcat,项目名称:Code-Samples,代码行数:34,代码来源:Email.py

示例11: sendEmail

# 需要导入模块: from email.Utils import COMMASPACE [as 别名]
# 或者: from email.Utils.COMMASPACE import join [as 别名]
def sendEmail(send_from, send_to, subject, text, cc_to=[], files=[], server="192.168.42.13"):
    assert type(send_to)==list
    assert type(files)==list

    msg=MIMEMultipart()
    msg.set_charset("utf-8")
    msg['From']=send_from
    msg['To']=COMMASPACE.join(send_to)

    if cc_to:
        assert type(cc_to)==list
        msg['cc']=COMMASPACE.join(cc_to)
        send_to.extend(cc_to)

    msg['Date']=formatdate(localtime=True)
    msg['Subject']=subject

    msg.attach(MIMEText(text))

    for f in files:
        part=MIMEBase('application', "octet-stream")
        part.set_payload(open(f, "rb").read())
        Encoders.encode_base64(part)
        part.add_header('Content-Disposition', 'attachment; filename="%s"'%Header(os.path.basename(f), 'utf-8'))
        msg.attach(part)

    smtp=smtplib.SMTP(server)
    smtp.sendmail(send_from, send_to, msg.as_string())
    smtp.close()
开发者ID:LamCiuLoeng,项目名称:vat,代码行数:31,代码来源:common.py

示例12: send_mail

# 需要导入模块: from email.Utils import COMMASPACE [as 别名]
# 或者: from email.Utils.COMMASPACE import join [as 别名]
def send_mail(p_send_from, p_send_to, p_send_cc, p_subject, p_text, p_files = [], p_server = "localhost"):
    try:
        assert type(p_send_to) == list
        assert type(p_send_cc) == list
        assert type(p_files) == list
    
        msg = MIMEMultipart()
        msg['From'] = p_send_from
        msg['To'] = COMMASPACE.join(p_send_to)
        msg['Cc'] = COMMASPACE.join(p_send_cc)
        msg['Date'] = formatdate(localtime = True)
        msg['Subject'] = p_subject
        msg.attach(MIMEText(p_text))
        
        for l_files in p_files:
            part = MIMEBase('application', "octet-stream")
            part.set_payload(open(l_files, "rb").read())
            Encoders.encode_base64(part)
            part.add_header('Content-Disposition', 'attachment; filename="%s"' % os.path.basename(l_files))
            msg.attach(part)
    
        smtp = smtplib.SMTP(p_server)
        smtp.sendmail(p_send_from, p_send_to + p_send_cc, msg.as_string())
        smtp.close()
        print "Email successfully sent..!"
        
    except Exception, e:
        print "\n* EXCEPTION DURING EMAIL SENDING: ", e
开发者ID:grmte,项目名称:ml,代码行数:30,代码来源:email_accumulated_results.py

示例13: send_mail

# 需要导入模块: from email.Utils import COMMASPACE [as 别名]
# 或者: from email.Utils.COMMASPACE import join [as 别名]
def send_mail(**a):
  assert type(a['send_to'])==list
  assert type(a['files'])==list

  msg = MIMEMultipart()
  msg['From'] = a['send_from']
  msg['To'] = COMMASPACE.join(a['send_to'])
  msg['cc'] = COMMASPACE.join(a['send_cc'])
  msg['Date'] = formatdate(localtime=True)
  msg['Subject'] = a['subject']

  msg.attach( MIMEText(a['text']) )


  for f in a['files']:
    part = MIMEBase('application', "octet-stream")
    part.set_payload( open(f,"rb").read() )
    Encoders.encode_base64(part)
    part.add_header('Content-Disposition', 'attachment; filename="%s"' % os.path.basename(f))
    msg.attach(part)

  try:
    smtp = smtplib.SMTP(a['server'])
    smtp.sendmail(a['send_from'], a['send_to']+a['send_cc'], msg.as_string())
    smtp.close()
  except SMTPException:
    pass
开发者ID:maxsocl,项目名称:xlparse,代码行数:29,代码来源:send_mail.py

示例14: reply_function

# 需要导入模块: from email.Utils import COMMASPACE [as 别名]
# 或者: from email.Utils.COMMASPACE import join [as 别名]
        def reply_function():
            msg = MIMEMultipart()
            send_from = cherrypy.session.get('_cp_username')+"@ecommunicate.ch"
            #msg['From'] = 
            send_to = re.findall(r'[^\;\,\s]+',to)
            send_cc = re.findall(r'[^\;\,\s]+',cc)

            for email_address in (send_to + send_cc):
                if email_address.split("@")[1] != "ecommunicate.ch":
                    return "Can only send emails to ecommunicate.ch e-mail addresses."

            msg['To'] = COMMASPACE.join(send_to)
            msg['CC'] = COMMASPACE.join(send_cc)
            msg['Date'] = formatdate(localtime=True)
            msg['Subject'] = subject
            msg['Message-ID'] = email.Utils.make_msgid()

            mime_applications = []

            l = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','0','1','2','3','4','5','6','7','8','9']

            if len(attachments) > 36:
                raise Exception

            for i,attachment in enumerate(attachments):
                if attachment.file != None and attachment.filename != "":
                    tmp_filename=os.popen("mktemp").read().rstrip('\n')
                    open(tmp_filename,'wb').write(attachment.file.read());
                    
                    if str(attachment.content_type) == "application/pdf":
                        mime_application = MIMEApplication(open(tmp_filename,'rb').read(),"pdf")
                        mime_application['Content-Disposition'] = 'attachment; filename="'+str(attachment.filename)+'"'
                        mime_application['Content-Description'] = str(attachment.filename)
                        mime_application['X-Attachment-Id'] = str("f_")+l[random.randint(0,35)]+l[random.randint(0,35)]+l[random.randint(0,35)]+l[random.randint(0,35)]+l[i]+l[random.randint(0,35)]+l[random.randint(0,35)]+l[random.randint(0,35)]+l[random.randint(0,35)]
                        mime_applications.append(mime_application)

            try:
                msg.attach(MIMEText(body))

                for mime_application in mime_applications:
                    msg.attach(mime_application)

                smtpObj = smtplib.SMTP(port=25)

                smtpObj.connect()

                smtpObj.sendmail(send_from, send_to+send_cc, msg.as_string())
                
                smtpObj.close()


            except Exception as e:
                print "Error: unable to send email", e.__class__
开发者ID:AndrewLevin,项目名称:open,代码行数:55,代码来源:reply.py

示例15: build_invitation

# 需要导入模块: from email.Utils import COMMASPACE [as 别名]
# 或者: from email.Utils.COMMASPACE import join [as 别名]
    def build_invitation(self, email_from='', email_to='', subject='', email_cc=[], email_bcc=[], reply_to=False,
                         attachments=None, message_id=None, references=None, object_id=False, headers={}, ):
        email_from = email_from or tools.config.get('email_from')
        assert email_from, "You must either provide a sender address explicitly or configure "\
                           "a global sender address in the server configuration or with the "\
                           "--email-from startup parameter."
        msg = MIMEMultipart()
        if not headers:
            headers = {}
        if not message_id:
            if object_id:
                message_id = tools.generate_tracking_message_id(object_id)
            else:
                message_id = make_msgid()
        msg['Message-Id'] = encode_header(message_id)
        if references:
            msg['references'] = encode_header(references)
        msg['Subject'] = encode_header(subject)
        msg['From'] = encode_rfc2822_address_header(email_from)
        del msg['Reply-To']
        if reply_to:
            msg['Reply-To'] = encode_rfc2822_address_header(reply_to)
        else:
            msg['Reply-To'] = msg['From']
        msg['To'] = encode_rfc2822_address_header(COMMASPACE.join(email_to))
        if email_cc:
            msg['Cc'] = encode_rfc2822_address_header(COMMASPACE.join(email_cc))
        if email_bcc:
            msg['Bcc'] = encode_rfc2822_address_header(COMMASPACE.join(email_bcc))
        msg['Date'] = formatdate()
        for key, value in headers.items():
            msg[ustr(key).encode('utf-8')] = encode_header(value)

        text_to_body_added = False
        if attachments:
            #it is assumed for now that only ics file is attached!!!
            for fname, fcontent in attachments:
                if not text_to_body_added and fname == 'invite.ics':
                    # Provide message description in body of message only as text for now; need fixes
                    if 'DESCRIPTION:' in fcontent and 'LOCATION' in fcontent.split('DESCRIPTION')[1]:
                        meeting_description_text = fcontent.split('DESCRIPTION:')[1].split('LOCATION')[0]
                    text_converted_to_html = self.plaintext2html(meeting_description_text, tabstop=4)
                    text_utf8 = re.sub(r'\\n', "</p><p>", text_converted_to_html)
                    alternative_part = MIMEMultipart(_subtype="alternative")
                    alternative_part.attach(MIMEText(text_utf8, _charset='utf-8', _subtype='html'))
                    msg.attach(alternative_part)
                #adding invitation stuff
                part = MIMEBase('text', 'calendar', charset='utf-8', method='REQUEST')
                part.set_payload(fcontent)
                msg.attach(part)
        return msg
开发者ID:enapps,项目名称:enapps-openerp-server,代码行数:53,代码来源:ir_mail_server.py


注:本文中的email.Utils.COMMASPACE.join方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。