• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python sendmail.sendmail函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中sendmail.sendmail函数的典型用法代码示例。如果您正苦于以下问题:Python sendmail函数的具体用法?Python sendmail怎么用?Python sendmail使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: requestPassword

def requestPassword(*args, **kwargs):
    if kwargs.get('submit') == "Get Password":
        mode = "pword"
    else:
        mode = "uname"            
    email = None
    if 'email' in kwargs:
        email = kwargs['email']
    if not email:
        return dict(message=_("Please enter the email address associated with your account"),
                    showform=True)
    result = User.select(User.q.email_address==email)
            
    try:
        if mode == "uname":
            user = result[0]
            mailtext = "Dear %(first_name)s,\n\nYour username is: %(user_name)s\n\nYou can login at:\n\n%(request_url)s/public/login\n\nIf you have any questions, please contact The Hub's hosting team at %(location_name)[email protected] or phone %(telephone)s.\n\nThank you very much.\n\nThe Hosting Team" %({'first_name':user.first_name, 'request_url':cherrypy.request.base, 'user_name':user.user_name, 'location_name':user.homeplace.name.lower().replace(' ', ''), 'telephone':user.homeplace.telephone})
            
            sendmail.sendmail(email, user.homeplace.name.lower().replace(' ', '') +'[email protected]','The Hub | username reminder',mailtext,[])
            return dict(message=_("""A confirmation email was sent to you. """),
                        showform=False)
        else:
            user = result[0]
            reminderkey = md5.new(str(random.random())).hexdigest()
            user.reminderkey = reminderkey
            mailtext = "Dear %(first_name)s,\n\nPlease click the link to reset your password:\n\n %(request_url)s/public/resetPassword?key=%(reminderkey)s\n\nIf you have any questions, please contact The Hub's hosting team at %(location_name)[email protected] or phone %(telephone)s.\n\nThank you very much.\n\nThe Hosting Team" %({'first_name':user.first_name, 'request_url':cherrypy.request.base, 'reminderkey':reminderkey, 'location_name':user.homeplace.name.lower().replace(' ', ''), 'telephone':user.homeplace.telephone})
            
            sendmail.sendmail(email, user.homeplace.name.lower().replace(' ', '') +'[email protected]','The Hub | password reminder',mailtext,[])
            return dict(message=_("""A confirmation email was sent to you. """),
                        showform=False)
    except IndexError:            
        return dict(message=_("The email was not correct"),
                               showform=True)
开发者ID:mightymau,项目名称:hubspace,代码行数:33,代码来源:login.py


示例2: sendMail

def sendMail():
    import sendmail
    sender = pf.cfg['mail/sender']
    if not sender:
        warning("You have to configure your email settings first")
        return
    
    res = askItems([
        _I('sender',sender,text="From:",readonly=True),
        _I('to','',text="To:"),
        _I('cc','',text="Cc:"),
        _I('subject','',text="Subject:"),
        _I('text','',itemtype='text',text="Message:"),
       ])
    if not res:
        return

    msg = sendmail.message(**res)
    print msg
    to = res['to'].split(',')
    cc = res['cc'].split(',')
    sendmail.sendmail(message=msg,sender=res['sender'],to=to+cc)
    print "Mail has been sent to %s" % to 
    if cc:
        print "  with copy to %s" % cc
开发者ID:BackupTheBerlios,项目名称:pyformex-svn,代码行数:25,代码来源:tools_menu.py


示例3: finish

def finish(newFiles):
    """
    Moved from Monitor class. Sends an email containing all new files.
    """
    if(len(newFiles) > 0):
        text = ""
        subject = "Moodle Report - "
        for course in newFiles:
	    text += "~"*5 + course + "~"*5 + "\n"
            if(len(newFiles[course]) > 0):
                subject += course + " "
            for file in newFiles[course]:
                if file[2]:
                    suffix = "Changed"
                else:
                    suffix = "New"
                text += file[0] + " - " + suffix + "\n"
                text += "Link: " + file[1] + "\n\n"
            text += "\n\n"
        text += "MoodleCheck.py - 1.1"
        subject += strftime("%d.%m.%Y")
        # Send the mail to every address in mails.txt
        mails = open("mails.txt", "r").readlines()
        sendmail.connectToServer()
        for mail in mails:
            mail = mail.strip()
            if len(mail) > 0 and not mail.startswith("#"):
                sendmail.sendmail(mail, subject, text)
        sendmail.closeConnection()
开发者ID:dominiks,项目名称:sitecheck,代码行数:29,代码来源:moodle.py


示例4: sendEmail

 def sendEmail(self,status):
     if not status:
         sendmail.sendmail(self.html.getCon(),self.email_address,self.mail_title + "[Fail]","[email protected]")
         raise Exception("混服步服失败")
     else:
         sendmail.sendmail(self.html.getCon(),self.email_address,self.mail_title + "[Succ]","[email protected]")
     logging.info("邮件已发送")
开发者ID:AmiLiY,项目名称:astoptool,代码行数:7,代码来源:deployMix.py


示例5: check_balance

 def check_balance(self,rooms):
     if isinstance(rooms,list):
         for room in rooms:
                 self.check_balance(room)
     else:
         self.get(self.url)
         data = urlencode(dict(self.validers.items() + [('DistrictDown',rooms.addr['DistrictDown'].encode('utf-8'))]))
         #pdb.set_trace()
         self.get(self.url, data)
         #try:
         #sorry for the ugly code, the page is incredibly awful and strange,
         #it has to post a long nonsence __VIEWSTATE and html was full of 
         #tables, somehow lxml.etree coudn't parse correctly.
         #en, urlencode only accepts utf8, and i'm too lazy to change the database.
         data = urlencode(dict(self.validers.items() + zip(rooms.addr.keys(),[a.encode('utf-8') for a in rooms.addr.values()]) + [('Submit','查询')]))
         #data = data.replace('=','%3d').replace('&','%26')  #quick fix, sorry for this but the server only accept this way,at the post.
         #print(data)
         html = self.get(self.url, data)
         n    = html.find('剩余电量(kWh)</th>')
         table= html[n:n+400]
         cells= re.findall(re.compile('<td>(.*?)</td>'),table)
         balance = cells[3]
         balance = float(balance)
         if balance < rooms.threshold:
             sendmail(rooms.email, u'{0}{1}快没电费啦!!!'.format(rooms.addr['BuildingDown'],rooms.addr['RoomnameText']), u'还剩{0}Kwh =w='.format(balance))
         rooms['balance'] = balance
         rooms['last_check'] = time.utcnow()
         rooms.save()
         return balance
         '''except HTTPError, e:
开发者ID:c19,项目名称:TJwarner,代码行数:30,代码来源:monitor.py


示例6: send_command

def send_command(recipients, subject, attachment):
    """Send email to recipients with subject and an attachment"""
    print 'Attachment: %s' %attachment
    print 'Recipients:'
    tos = recipients.split()
    for to in tos:
        print to
    sendmail(tos, subject, attachment)
开发者ID:mine260309,项目名称:daily-feed-push,代码行数:8,代码来源:sendmobi.py


示例7: contact

def contact():
	if request.method == 'GET':
		return render_template('contact.html')
	elif (request.method == 'POST'):
		name=request.form['name']
        email=request.form['email']
        subject=request.form['subject']
        message=request.form['message']
        sendmail(name,email,subject,message)
        return "Message sent!"
开发者ID:renaldopringle,项目名称:info3180-lab3,代码行数:10,代码来源:run.py


示例8: sendFile

 def sendFile(self, fname):
     login = self.taskinfo.get('sender'), self.taskinfo.get('mailpass')
     cc = self.taskinfo.get('cc')
     bcc = self.taskinfo.get('bcc')
     to = self.taskinfo.get('receiver')
     sender = self.taskinfo.get('sender')
     subject = self.taskinfo.get('mailtitle')
     text = self.taskinfo.get('mailtext')
     server = self.taskinfo.get('mailserver')
     sendmail.sendmail(login, sender, to, cc, bcc, subject, text, fname, server)  
开发者ID:tjgao,项目名称:autoReport,代码行数:10,代码来源:task.py


示例9: submit

def submit(name, desc, source, pipeline):
    file_name = name.split("(")[0]
    if len(file_name) > 0 and len(desc) > 0 and len(desc) < 100 and len(source) > 0 and len(source) < 2000:
        file_name = file_name.split(" ")[0]
        source = source.replace("_SLASH", "/")

        if pipeline.find("@") > 0:
            pipeline = pipeline.split("@")[0]

            # make a folder, and write the source
        os.system("mkdir %s" % file_name)
        writer = open(r"%s/%s.rkt" % (file_name, file_name), "w")
        writer.write(source)
        writer.close()

        ## DON'T LET THEM OVERWRITE
        if os.path.exists("%s"):
            return "Sorry, that's already been taken."

            # add to the queue
        writer = open("queue", "a")

        # generate a code
        code = ""
        for i in range(10):
            code += str(random.randint(0, 9))

        writer.write(name + "@")
        writer.write(file_name + "@")
        writer.write(desc + "@")
        writer.write(pipeline + "@")
        writer.write(code + "\n")
        writer.close()

        # email them
        body = """
Hi %s,
		 			  
To confirm your recent submission of "%s", please click the link below.
		 			  
http://96.242.135.162:7777/confirm/%s
		 			  
Thanks,
((TheSchemeIndex))""" % (
            pipeline,
            name,
            code,
        )

        sendmail("%[email protected]" % pipeline, 'Confirm your submission of "%s"' % name, body)

        print "email sent"
        return "email sent"
    else:
        return "ERR"
开发者ID:jdan,项目名称:code,代码行数:55,代码来源:main.py


示例10: send_notify

def send_notify():
    if len(sys.argv) != 2:
        print 'Usage:\n\t{0} <file>\nSend a notification to all users.'.format(sys.argv[0])
        return 1
    file = sys.argv[1]
    fullpath = os.path.abspath(file)
    filename = os.path.basename(fullpath)
    print 'To send {0} to all users...'.format(file)
#    print 'Full path: {0}, filename: {1}'.format(fullpath, filename)
    recipients = utils.get_recipients()
    sendmail(recipients, filename, fullpath)
    print 'Done'
开发者ID:mine260309,项目名称:daily-feed-push,代码行数:12,代码来源:send_notify.py


示例11: sendTextEmail

def sendTextEmail(message_name, location=None, data={}, extra_data={}, to=None, cc=None, sender=None, notifydevonfailure=True):
    message = messages.bag[message_name]
    message_dict = message.make(location, data, extra_data)
    sender = sender or message_dict['sender']
    to = to or message_dict['to']
    cc = cc or message_dict.get('cc')
    subject = message_dict['subject']
    body = message_dict['body']
    try:
        sendmail.sendmail(to, cc=cc, sender=sender, subject=subject, body=body)
    except Exception, err:
        applogger.exception("alertslib failure")
开发者ID:mightymau,项目名称:hubspace,代码行数:12,代码来源:__init__.py


示例12: main

def main(args):
    config = read_config(args)
    logger.debug(args)
    recipients = args.recipients or config['recipients']
    if not recipients:
        logger.error("Recipients list is empty. Set them up once using command line arguments")
        return -1

    ipfile = osp.join(xdg.save_config_path(myname), 'ip')

    try:
        logger.debug("Reading previous IP file: %s", ipfile)
        with open(ipfile) as f:
            oldip = f.read().strip()
    except IOError as e:
        logger.warn(e)
        oldip = ""

    try:
        newip = upnp.external_ip()
    except (upnp.UpnpError, upnp.socket.error) as e:
        logger.error(e)
        return

    if newip == oldip:
        logger.info("IP is still %s", oldip)
        if not args.force:
            return
    elif newip == '0.0.0.0':
        logger.info("IP changed to %s, ignoring", newip)
        if not args.force:
            return
    else:
        logger.info("IP changed from %s to %s", oldip, newip)
        logger.debug("Saving new IP file", ipfile)
        try:
            with open(ipfile, 'w') as f:
                f.write('%s\n' % newip)
        except IOError as e:
            logger.error(e)

    try:
        logger.info("Sending email")
        sendmail.sendmail(myname,
                          recipients,
                          "External public IP changed to %s" % newip,
                          newip,
                          debug=args.debug,)
    except (sendmail.smtplib.SMTPException, sendmail.socket.gaierror) as e:
        logger.error(e)

    logger.info("Notifying NoIP.com")
    noip.main(["-v"] if args.debug else [])
开发者ID:MestreLion,项目名称:ddns-tools,代码行数:53,代码来源:dyndns_update.py


示例13: emit

 def emit(self, record):
     """
     Emit a record.
     
     Format the record and send it to the specified addressees.
     """
     try:
         msg = self.format(record)
         sendmail.sendmail(self.fromAddr, self.toAddrs, self.subject, message=msg, method=self.method)
     except (KeyboardInterrupt, SystemExit):
         raise
     except:
         self.handleError(record)
开发者ID:AlfiyaZi,项目名称:python-utils,代码行数:13,代码来源:loggingutil.py


示例14: findpassword

def findpassword():
    if request.method == 'GET':
        return render_template('findpassword.html')
    else:
        email = request.form['email']
        if len(user.query.filter_by(Email=email).all()) == 0:
            flash("No this email!!")
            return render_template('findpassword.html')
        else:
            password = user.query.filter_by(Email=email).first().Password
            sendmail(email, 'Find Your Password!!!! -by flask-user', 'your password is %s' % password)
            flash("please check your email!!your password is find!!")
            return redirect(url_for('login'))
开发者ID:Yougeme,项目名称:flask-user-system,代码行数:13,代码来源:myapp.py


示例15: handler

	def handler(self, context):
		import string
		if self.form.has_key("email"):
			email = self.form['email'].value
		if string.find(email,"@") == -1:
			self.do_error ("gimme a real email. i need it to verify your existence. :-P")
		if len(email) < 3:
			self.do_error ("gimme a real email. i need it to verify your existence. :-P")

		import HaloRadio.UserListMaker as UserListMaker

		ulm = UserListMaker.UserListMaker()

		ulm.GetByEmail(email)

		if  len(ulm.list) < 1:
			self.do_error("no user found for that email")
		if  len(ulm.list) > 1:
			self.do_error("too many users found for that email")
		u = ulm.GetUser(0)

		hash = u.GetNewHash()	

		import sendmail

		emailstr = """From: %(from)s
To: %(to)s
Bcc: %(bcc)s
Subject: %(site_name)s password request

%(user)s - 

someone requested a forgotten password...

  click here : 
%(siteurl)s/?action=verify&user=%(user)s&hash=%(code)s



"""% {
	"from": "[email protected]%s"%(self.config["general.hostname"]),
	"to": email,
	"site_name": "halo_radio",
	"bcc": "[email protected]",
	"code": hash,
	"user": u.name,
	"siteurl": self.config["general.cgi_url"]
}

		sendmail.sendmail( "[email protected]%s"%(self.config["general.hostname"]) , [ email, "[email protected]" ], emailstr )
开发者ID:ph1l,项目名称:halo_radio,代码行数:50,代码来源:forgotPasswordPost.py


示例16: main

def main():
    arg_parser = argparse.ArgumentParser(description="Send mail to members")

    arg_parser.add_argument('-t', '--text_file', required=True,
                            dest='text_file')
    arg_parser.add_argument('-s', '--subject', required=True, dest='subject')
    arg_parser.add_argument('-H', '--html_file', dest='html_file')
    arg_parser.add_argument("-u", '--single_user', dest='user')

    args = arg_parser.parse_args()
    if args.text_file[0] != "/":
        try:
            txtmsg = open(default_template_location +
                          "/" + args.text_file, "r").read().decode("utf-8")
        except Exception:
            txtmsg = open(args.text_file, "r").read().decode("utf-8")
    else:
        txtmsg = open(args.text_file, "r").read().decode("utf-8")
    if args.html_file:

        if args.html_file[0] != "/":
            try:
                htmlmsg = open(default_template_location +
                               "/" + args.html_file,
                               "r").read().decode("utf-8")
            except Exception:
                htmlmsg = open(args.html_file, "r").read().decode("utf-8")
        else:
            htmlmsg = open(args.html_file, "r").read().decode("utf-8")

    if User.myself() not in Privilege("memberinfo").member:
        print "You're not in the memberinfo group, "\
            "so you don't have permission to send mail to members"
        sys.exit(1)
    msg = MIMEMultipart('alternative')
    msg.attach(MIMEText(txtmsg, 'plain'))
    if htmlmsg is not None:
        msg.attach(MIMEText(htmlmsg, 'html'))
    # for each current member
    if args.user is None:
        for u in User.search(tcdnetsoc_membership_year=current_session()):
            print "sending to %s" % u
            u.sendmail(msg,
                       From='Netsoc PRO <[email protected]>',
                       Subject="[Netsoc] %s" % args.subject)
    else:
        sendmail(msg,
                 From='Netsoc PRO <[email protected]>',
                 To=args.user,
                 Subject="[Netsoc] %s" % args.subject)
开发者ID:netsoc,项目名称:admin_utils,代码行数:50,代码来源:send_spam.py


示例17: reset_password

 def reset_password(self):
     if not self.has_account():
         raise Exception("User account is disabled,\
                         password cannot be reset")
     pw = generate_password()
     self.passwd(pw)
     addr = self.get_attribute("mail")
     if addr is None:
         lwarn("No mail address recorded for user %s (%s),\
               can't send password reset message" %
               (self.get_attribute("uid"), self.get_attribute("cn")))
     else:
         sm.sendmail("password_reset",
                     to=addr, username=self.uid, password=pw)
开发者ID:netsoc,项目名称:nd,代码行数:14,代码来源:nd.py


示例18: send_mail

def send_mail(title, send, recv, mailfile, mode):
    # send to jira comment
    if mode == 'mail':
    # 메일 전송
        #logging.info("mail success %s" % mailfile)
        f = open(mailfile, 'r')
        msg = f.read().replace('\n','\r\n')
        args = ['-v', 'mailserver','-s',title, '-f',send, '-r',recv, '-m',msg , '-t', 'html']
        f.close()
        logging.info("send mail : %s" % mailfile)
    else: 
        args = ['-v', 'send mail','-s',title, '-f',send, '-r',recv, '-m',mailfile  ]
        logging.info("send mail : Jira comment")
        
    sendmail.sendmail(args)
开发者ID:juner417,项目名称:xylitol,代码行数:15,代码来源:commons.py


示例19: POST

 def POST(self):
     room = self.check(web.input())
     print(room)
     try:
         yield("checking ...")
         balance = monitor.check_balance(room)
         yield("sending mail...")
         sendmail(room.email, u'{0}{1}电量剩余{2} Kwh'.format(room.addr['BuildingDown'], room.addr['RoomnameText'], balance),
                  u'电量低于{0}时将发送提示邮件到此邮箱。\n<a href="{1}">点此设置开学后再提醒或清除账号</a>'.format(room.threshold, setting_url(room.addrindex))
                 )
         room.save()
         yield("done, check your email.")
     except Exception, e:
         web.SeeOther('/fail')
         return
开发者ID:c19,项目名称:TJwarner,代码行数:15,代码来源:router.py


示例20: notify_contacts

    def notify_contacts(self):
	if not self.mailto:
	    return None	
 
	to = self.mailto
	subject = "QA Test %s %s" % (self.name, self.status)
	log = self.logfile
	body = """
	Hello PlanetLab developer,
	
	The test script for your module has %(status)s. Please review this
	tests log for further details.
	%(log)s
	""" % locals()
		
	sendmail(to, subject, body)
开发者ID:dreibh,项目名称:planetlab-lxc-tests,代码行数:16,代码来源:Step.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python senf.bytes2fsn函数代码示例发布时间:2022-05-27
下一篇:
Python sendgrid.SendGridClient类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap