本文整理汇总了Python中sendmail.sendmail函数的典型用法代码示例。如果您正苦于以下问题:Python sendmail函数的具体用法?Python sendmail怎么用?Python sendmail使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sendmail函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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)
示例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
示例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()
示例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("邮件已发送")
示例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:
示例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)
示例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!"
示例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)
示例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"
示例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'
示例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")
示例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 [])
示例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)
示例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'))
示例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 )