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


Python Mail.send方法代码示例

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


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

示例1: scan

# 需要导入模块: from mail import Mail [as 别名]
# 或者: from mail.Mail import send [as 别名]
 def scan():
     Scan.create(date=datetime.datetime.utcnow(),network_ssid=Command.ssid())
     discovered = Command.host_discovery()
     existing = [[i.hostname,i.ip_address] for i in Host.select(Host.hostname,Host.ip_address)]
     difference = [i for i in discovered if i not in existing]
     hosts = [Host.create(hostname=i[0],ip_address=i[1]) for i in discovered]
     if difference:
         Mail.send(Mail.format(difference))
开发者ID:balag3,项目名称:NetworkScan,代码行数:10,代码来源:scanmodels.py

示例2: __init__

# 需要导入模块: from mail import Mail [as 别名]
# 或者: from mail.Mail import send [as 别名]
class Message:


    def __init__(self):
        self.__LOG_TAG__ = "MESSAGE"

        self.__mail = Mail(self.__read_mail_values())
        self.__whatsapp = WhatsApp()

    def __read_mail_values(self):
        """Read e-mail values in xml configuration file"""

        tree = xml.dom.minidom.parse("../config.xml")
        config = tree.getElementsByTagName('config')[0]
        msg_config = config.getElementsByTagName('msg_config')[0]
        l_email = msg_config.getElementsByTagName('email')[0]

        l_description = l_email.getAttribute('description')
        l_host = l_email.getAttribute('host')
        l_port = int(l_email.getAttribute('port'))
        l_login = l_email.getAttribute('login')
        l_password = l_email.getAttribute('password')
        l_sender = l_email.getAttribute('sender')
        l_target = l_email.getAttribute('target') #for tests. later can be any user's email
        l_complete = True

        log.info(self.__LOG_TAG__, "Infos of e-mail read [%s]" %l_sender)

        return l_description, l_host, l_port, l_login, l_password, l_sender, l_target, l_complete

    def is_connected_mail(self):
        """Check if email server is connected"""

        return self.__mail.is_connected()

    def connect_mail(self):
        """Connect to email server."""

        self.__mail.connect();

    def test_connection_mail(self):
        """Try to reconnect to the server if it is not connected."""
        
        self.__mail.test_connection()

    def disconnect_mail(self):
        """Disconnecd from email server"""

        self.__mail.disconnect()

    def send_mail(self, p_target, p_subject="[no_subject]", p_msg="Hello!"):
        """send one or more emails
        target: str, list or tuple
        """

        self.__mail.send(p_target, p_subject, p_msg)
开发者ID:guikingma,项目名称:Jarbas,代码行数:58,代码来源:message.py

示例3: changeemail

# 需要导入模块: from mail import Mail [as 别名]
# 或者: from mail.Mail import send [as 别名]
    def changeemail(self, oldemail, newemail, password):
        Validator.email(oldemail)
        Validator.email(newemail)
        Validator.password(password)

        if self.user.get(oldemail)['password'] != Secret.hash(password, SALT):
            raise RiverException('The password is incorrect for this user.')
        
        token = Secret.generate(16)

        self.user.update(oldemail, email=newemail, enabled=False, token=token)

        Mail.send(MAIL_FROM, newemail, 'RiverID Email Change', token)
开发者ID:brianherbert,项目名称:riverid,代码行数:15,代码来源:api.py

示例4: requestpassword

# 需要导入模块: from mail import Mail [as 别名]
# 或者: from mail.Mail import send [as 别名]
    def requestpassword(self, email):
        Validator.email(email)

        token = Secret.generate(16)

        if self.user.exists(email):
            subject = 'RiverID: Please confirm your password change.'
            self.user.update(email, token=token)
        else:
            subject = 'RiverID: Please confirm your email address.'
            user_id = Secret.generate(128)
            self.user.insert(email, id=user_id, enabled=False, token=token)

        Mail.send(MAIL_FROM, email, subject, token)
开发者ID:brianherbert,项目名称:riverid,代码行数:16,代码来源:api.py

示例5: post

# 需要导入模块: from mail import Mail [as 别名]
# 或者: from mail.Mail import send [as 别名]
    def post(self):
        smtp_server  = self.get_argument("smtp_server").encode("utf-8")
        smtp_eamil    = self.get_argument("smtp_email").encode("utf-8")
        smtp_account = self.get_argument("smtp_account").encode("utf-8")
        smtp_passwd  = self.get_argument("smtp_passwd").encode("utf-8")
	try:
    	    subject = '发送邮件测试' 
    	    content = '本邮件由发布系统自动发送测试邮件,请勿回复!!谢谢!!'
	    mail = Mail(smtp_server,smtp_account,smtp_passwd )
	    tolist = [smtp_eamil] 
    	    mail.send(subject, content, tolist) 
	    self.write("系统向测试%s邮箱发送了一封测试邮件,请查看!"%smtp_eamil)
	except:
	   self.write("测试失败,请确认输入是否正确") 
开发者ID:xiaoyang2008mmm,项目名称:deploy_platform,代码行数:16,代码来源:views.py

示例6: get

# 需要导入模块: from mail import Mail [as 别名]
# 或者: from mail.Mail import send [as 别名]
  def get(self):
    ctl = self.request.get('CTL')
    sender = self.request.get('SENDER')
    receiver = self.request.get('RECEIVER')
    content = self.request.get('CONTENT')

    vendor = Vendor()

    if ctl == '102':
      sender = Mail()
      sender.send(sender, vendor.parse(receiver), receiver, content)
      self.response.out.write("Done sending mail! " + str(sender) + " " + str(receiver) + " " + str(content))
    elif ctl == '103':
      self.response.out.write(str(sender) + " ")
      self.response.out.write(vendor.parse(receiver) + " ")
      self.response.out.write(str(receiver) + " ")
      self.response.out.write(str(content))
开发者ID:RepoCastle,项目名称:MsgSwitch,代码行数:19,代码来源:msgswitch.py

示例7: requestpassword

# 需要导入模块: from mail import Mail [as 别名]
# 或者: from mail.Mail import send [as 别名]
    def requestpassword(self, email, mailbody, mailfrom = None, mailsubject = None):
        Validator.email(email)

        token = Secret.generate(16)

        if mailfrom is None:
            mailfrom = MAIL_FROM

        if self.user.exists(email):
            if mailsubject is None:
                mailsubject = _('CrowdmapID: Please confirm your password change.')
            self.user.update(email, token=token)
        else:
            if mailsubject is None:
                mailsubject = _('CrowdmapID: Please confirm your email address.')
            user_id = Secret.generate(128)
            self.user.insert(email, id=user_id, enabled=False, token=token)

        Mail.send(mailfrom, email, mailsubject, mailbody, token=token)
开发者ID:evansims,项目名称:riverid-python,代码行数:21,代码来源:api.py

示例8: changeemail

# 需要导入模块: from mail import Mail [as 别名]
# 或者: from mail.Mail import send [as 别名]
    def changeemail(self, oldemail, newemail, password, mailbody, mailfrom = None, mailsubject = None):
        Validator.email(oldemail)
        Validator.email(newemail)
        Validator.password(password)

        if self.user.get(oldemail)['password'] != Secret.hash(password, SALT):
            raise RiverException(_('The password is incorrect for this user.'))

        if self.user.exists(newemail):
            raise RiverException(_('The new email address has already been registered.'))

        if mailsubject is None:
            mailsubject = _('CrowdmapID Email Change')

        if mailfrom is None:
            mailfrom = MAIL_FROM

        token = Secret.generate(16)

        self.user.update(oldemail, email=newemail, enabled=False, token=token)

        Mail.send(mailfrom, newemail, mailsubject, mailbody, token=token)
开发者ID:evansims,项目名称:riverid-python,代码行数:24,代码来源:api.py

示例9: send

# 需要导入模块: from mail import Mail [as 别名]
# 或者: from mail.Mail import send [as 别名]
    def send(self):
        mail_configs = {}
        '''
        set appid and appkey
        '''
        mail_configs['appid'] = self.appid
        mail_configs['appkey'] = self.appkey

        '''
        set sign_type,if is set
        '''
        if self.sign_type != '':
            mail_configs['sign_type'] = self.sign_type

        '''
        init mail class
        '''
        mail = Mail(mail_configs)

        '''
        build request and send email and return the result
        '''
        return mail.send(self.build_request())
开发者ID:dzhuang,项目名称:SUBMAIL_PYTHON_SDK,代码行数:25,代码来源:mail_send.py

示例10: send_email

# 需要导入模块: from mail import Mail [as 别名]
# 或者: from mail.Mail import send [as 别名]
def send_email(email, subject, content):
    assert check_email(email), 'invalid email address:%s' % email
    return Mail.send([email], subject, content)
开发者ID:MythRen,项目名称:ios-server,代码行数:5,代码来源:util.py

示例11: _send_interview_details

# 需要导入模块: from mail import Mail [as 别名]
# 或者: from mail.Mail import send [as 别名]
 def _send_interview_details(self, slot, applicant):
     message = "Dear %s!\n\nYour You have an interview at: %s\nApplicant's name: %s\n\nHave fun!" \
               % (self.first_name + ' ' + self.last_name, slot.start, applicant.first_name + ' ' + applicant.last_name)
     Mail.send(message, self.email, 'Interview details')
开发者ID:CodecoolBP20161,项目名称:python-school-system-with-orm-sf,代码行数:6,代码来源:models.py

示例12: open

# 需要导入模块: from mail import Mail [as 别名]
# 或者: from mail.Mail import send [as 别名]
    with open(database, 'r') as f:
        for num in f:
            sent.append(num.strip())
    return set(sent)

press = get_press() # get article # of articles in press
sent = get_sent('sent.txt') # get article # of sent e-mails
to_send = press.difference(sent) # difference of sets are the e-mails to send

infodb = {} # table of article # and e-mails
with open('list_mail.txt', 'r') as input_file:
    next(input_file)
    for line in input_file:
        line = line.strip()
        info = line.split('\t')
        infodb[info[0][0:12]] = (info[1], info[2], info[3])
for artcod in to_send:
    manuscript = Manuscript(artcod)
    if (infodb[artcod][2] == 'Brazil'): language = 'pt'
    else: language = 'en'
    auth_info = [infodb[artcod][0], 'n', language, infodb[artcod][1].lower()]
    author = Author(auth_info)
    mail = Mail(author, manuscript)
    mail.send()
    print '%s: e-mail enviado para %s' % (artcod, infodb[artcod][1].lower())
with open('sent.txt', 'a') as sent: # write in sent.txt the article # of sent
    for artcod in to_send:
        sent.write(artcod)
        sent.write('\n')
print 'Finished!'
开发者ID:holypriest,项目名称:edit-scripts,代码行数:32,代码来源:mail_script.py

示例13: motionDetected

# 需要导入模块: from mail import Mail [as 别名]
# 或者: from mail.Mail import send [as 别名]
	def motionDetected(self, idDevice, code):

		con = ""

		result = 0

		try:
			con = mdb.connect(myconfig.urlDb, myconfig.userDb, myconfig.passDb, myconfig.nameDb, charset = "utf8")
			cur = con.cursor(mdb.cursors.DictCursor)
			consulta = myconfig.selectLocationSecurity % (idDevice, code)
			cur.execute(consulta)
			row = cur.fetchone()

			if int(row['RIPMotion']) == 1: #Detector de movimiento activado

				if int(row['security']) == 1: #Seguridad activada

					if int(row['alarm']) == 0: #Alarma aun no activada
 
						#Actualizamos el estado del dispositivo a alarma
						consulta = myconfig.updateAlarm % ("1", idDevice)
						cur.execute(consulta)
						con.commit()

						#Introducimos la alerta en el registro de alertas
						consulta = myconfig.insertAlert % ("2", idDevice)
						cur.execute(consulta)
						con.commit()

						#Obtenemos los dispositivos camara de esa ubicacion
						consulta = myconfig.selectDevicesLocationOpenPortCameras % (row['idLocation'])
						cur.execute(consulta)
						cameras = cur.fetchall()


						subject = u"Domotics Alerta seguridad %s" % (row['nameLocation'])
						message = u"Hola %s.\n\nTu dispositivo %s ha dectado movimiento en su %s.\n\n" % (row['nameUser'], row['nameDevice'], row['nameLocation'])
					
						photos = []

						if len(cameras) > 0:

							message +=u"Adjuntamos imágenes de sus cámaras de seguridad:\n"

							for camera in cameras:

								try:
									resultPhoto = self.getImageForDeviceCamera(camera['publicIp'], camera['port'], camera['code'])
									photos.append(resultPhoto)
									message+=u"%s\n"%(camera['name'])

								except:
									pass

						message+=u"\nAtentamente Domotics.\n\n"

						m = Mail()

						m.send(row['email'], subject, message, photos)

						#Notificamos a los dispositivos la alerta
						consulta = myconfig.selectDevicesLocationOpenPort % (row['idLocation'])
						cur.execute(consulta)
						devices = cur.fetchall()

						for device in devices:

							try:

								#Actualizamos el estado del dispositivo a alarma
								consulta = myconfig.updateAlarm % ("1", device['id'])
								cur.execute(consulta)
								con.commit()

								self.setDeviceAlarmMode(device['publicIp'], device['port'], device['code'])
								
							except:
								pass

						#Notificamos a los dispositivos de otras ubicaciones la alerta
						consulta = myconfig.selectDevicesOtherLocationOpenPort % (row['idLocation'])
						cur.execute(consulta)
						devicesOtherLocation = cur.fetchall()


						for device in devicesOtherLocation:

							try:
								self.setDeviceOtherLocationNotification(device['publicIp'], device['port'], device['code'])
							except:
								pass

						result = 1
		

					else:

						#Comprobamos duplicados
						consulta = myconfig.checkInsertAlert % ("1", idDevice)
						cur.execute(consulta)
#.........这里部分代码省略.........
开发者ID:PascualArroyo,项目名称:Domotics,代码行数:103,代码来源:Server.py

示例14: signIn

# 需要导入模块: from mail import Mail [as 别名]
# 或者: from mail.Mail import send [as 别名]
	def signIn(self, login, name, email, password):

		con = ""
		result = 0

		try:
			con = mdb.connect(myconfig.urlDb, myconfig.userDb, myconfig.passDb, myconfig.nameDb, charset = "utf8")
			cur = con.cursor(mdb.cursors.DictCursor)
			consulta = myconfig.selectMailExists % (email)
			cur.execute(consulta)
			response = cur.fetchone()

			if response == None:

				consulta = myconfig.selectUserExists % (login)
				cur.execute(consulta)
				response = cur.fetchone()

				if response == None:

					code = randint(100000,999999)
					text = "Ya casi estas registrado en Domotics.\nPara completar el codigo de verificacion de tu registro es %s.\n\nEquipo de Domotics" % (code)

					m = Mail()

					m.send(email, "Registro Domotics", text, [])

					consulta = myconfig.insertSignIn % (login, name, email, password, code)
					cur.execute(consulta)
					con.commit()

					result = 1

				else:
					result = 2


    		#Re-Send Code and update
			else:

				consulta = myconfig.selectMailExistsWithoutCheck % (email)
				cur.execute(consulta)
				response = cur.fetchone()

				if response == None:
					result = 3


				else:

					consulta = myconfig.selectUserExistsCheck % (login)
					cur.execute(consulta)
					response = cur.fetchone()

					if response == None:

						code = randint(100000,999999)
						text = "Ya casi estas registrado en Domotics.\nPara completar el codigo de verificacion de tu registro es %s.\n\nEquipo de Domotics" % (code)

						m = Mail()

						m.send(email, "Registro Domotics", text, [])

						consulta = myconfig.updateSignIn % (login, name, password, code, email)

						cur.execute(consulta)
						con.commit()

						result = 1


					else:
						result = 2



		except mdb.Error, e:
			#print "Error %d: %s" % (e.args[0],e.args[1])

			if con:
				con.rollback()
开发者ID:PascualArroyo,项目名称:Domotics,代码行数:83,代码来源:Server.py

示例15: _send_interview_slot_email

# 需要导入模块: from mail import Mail [as 别名]
# 或者: from mail.Mail import send [as 别名]
 def _send_interview_slot_email(self, mentors):
     message = "Dear %s!\n\nYour interview's time: %s\nAssigned mentors: %s, %s\n\n See you soon!" \
               % (self.first_name + ' ' + self.last_name, self.interview_slot.start,
                  mentors[0].first_name + ' ' + mentors[0].last_name,
                  mentors[1].first_name + ' ' + mentors[1].last_name)
     Mail.send(message, self.email, 'Interview time')
开发者ID:CodecoolBP20161,项目名称:python-school-system-with-orm-sf,代码行数:8,代码来源:models.py


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