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


Python yagmail.SMTP属性代码示例

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


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

示例1: notify_ip_change

# 需要导入模块: import yagmail [as 别名]
# 或者: from yagmail import SMTP [as 别名]
def notify_ip_change(newIp):

    # msg = MIMEText("Alert! The server's IP has changed to %s" % newIp)

    contents = urllib2.urlopen("http://build.myrobotlab.org:8888/setIpAddress?ipaddress=" + newIp).read()

    # yagmail.SMTP('supertick@gmail.com').send('supertick@gmail.com', "ip " + newIp)

    # sender = 'work-e@myrobotlab.org'
    # recipient = 'supertick@gmail.com'
    # msg['Subject'] = 'Alert - IP address has changed'
    # msg['From'] = sender
    # msg['To'] = recipient

    # Send the message via our own SMTP server, but don't include the
    # envelope header.
    # s = smtplib.SMTP('localhost')
    # s.sendmail(sender, recipient, msg.as_string())
    # s.quit()
# [notify_if_change ends] 
开发者ID:MyRobotLab,项目名称:pyrobotlab,代码行数:22,代码来源:ip_change_notifier.py

示例2: send_notification

# 需要导入模块: import yagmail [as 别名]
# 或者: from yagmail import SMTP [as 别名]
def send_notification(self, subject="OctoPrint notification", body=[""], snapshot=True):

		# If a snapshot is requested, let's grab it now.
		if snapshot:
			snapshot_url = self._settings.global_get(["webcam", "snapshot"])
			if snapshot_url:
				try:
					import urllib
					filename, headers = urllib.urlretrieve(snapshot_url, tempfile.gettempdir()+"/snapshot.jpg")
				except Exception as e:
					self._logger.exception("Snapshot error (sending email notification without image): %s" % (str(e)))
				else:
					body.append(yagmail.inline(filename))

		# Exceptions thrown by any of the following lines are intentionally not
		# caught. The callers need to be able to handle them in different ways.
		mailer = yagmail.SMTP(user={self._settings.get(['mail_username']):self._settings.get(['mail_useralias'])}, host=self._settings.get(['mail_server']),port=self._settings.get(['mail_server_port']), smtp_starttls=self._settings.get(['mail_server_tls']), smtp_ssl=self._settings.get(['mail_server_ssl']))
		emails = [email.strip() for email in self._settings.get(['recipient_address']).split(',')]
		mailer.send(to=emails, subject=subject, contents=body, headers={"Date": formatdate()}) 
开发者ID:anoved,项目名称:OctoPrint-EmailNotifier,代码行数:21,代码来源:__init__.py

示例3: send_email_163

# 需要导入模块: import yagmail [as 别名]
# 或者: from yagmail import SMTP [as 别名]
def send_email_163(subject, body, file):
    # 配置163发送邮件的主体账户选项
    yag = yagmail.SMTP(user='xugongli2012@163.com', password='', host='smtp.163.com', port='465')
    body = body
    # 配置接收邮件的邮箱
    yag.send(to=['982749459@qq.com'], subject=subject, contents=[body, r'%s' % file])

# Obey robots.txt rules 
开发者ID:xugongli,项目名称:poi_spider,代码行数:10,代码来源:settings.py

示例4: smtp

# 需要导入模块: import yagmail [as 别名]
# 或者: from yagmail import SMTP [as 别名]
def smtp(self):
        if self._smtp is None:
            from yagmail import SMTP
            self._smtp = SMTP(self.email, **self._kwargs)
        return self._smtp 
开发者ID:zbarge,项目名称:stocklook,代码行数:7,代码来源:emailsender.py

示例5: test_one

# 需要导入模块: import yagmail [as 别名]
# 或者: from yagmail import SMTP [as 别名]
def test_one():
    """ Tests several versions of allowed input for yagmail """
    yag = SMTP(smtp_skip_login=True, soft_email_validation=False)
    mail_combinations = get_combinations(yag)
    for combination in mail_combinations:
        print(yag.send(**combination)) 
开发者ID:kootenpv,项目名称:yagmail,代码行数:8,代码来源:all_test.py

示例6: send_email

# 需要导入模块: import yagmail [as 别名]
# 或者: from yagmail import SMTP [as 别名]
def send_email(self, name=None, attachments=None):
        """Send an email with the analysis results."""
        if name is None:
            name = self.local_path
        if attachments is None:
            attachments = [self.pdf_filename]
        elif attachments == '':
            attachments = []
        # compose message
        current_time = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
        if self.config['email']['enable-all']:
            statement = 'The pylinac watcher analyzed the file named or containing "{}" at {}. '
            statement += 'The analysis results are in the folder "{}".'
        elif self.config['email']['enable-failure']:
            statement = 'The pylinac watcher analyzed the file named or containing "{}" at {} and '
            statement += 'found something that failed your configuration settings.'
            statement += 'The analysis results are in the folder "{}".'
        statement = statement.format(name, current_time, osp.dirname(self.full_path))
        # send the email
        contents = [statement] + attachments
        recipients = [recipient for recipient in self.config['email']['recipients']]
        yagserver = yagmail.SMTP(self.config['email']['sender'], self.config['email']['sender-password'])
        yagserver.send(to=recipients,
                       subject=self.config['email']['subject'],
                       contents=contents)
        logger.info("An email was sent to the recipients with the results") 
开发者ID:jrkerns,项目名称:pylinac,代码行数:28,代码来源:watcher.py


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