rbh-acct-report.py 文件源码

python
阅读 18 收藏 0 点赞 0 评论 0

项目:lustre-scripts 作者: GSI-HPC 项目源码 文件源码
def send_mail( server, subject, sender, receiver, text, filepath ):

   msg = MIMEMultipart()
   msg['Subject'] = subject
   msg['From']    = sender
   msg['To']      = ', '.join( receiver )

   msg.attach( MIMEText( text ) )

   filename = os.path.split( filepath )[1]
   filetype = filename.split( '.' )[1]

   img = MIMEImage( file( filepath ).read(), _subtype=filetype )
   img.add_header( 'Content-Disposition', "attachment; filename= %s" % filename )

   msg.attach( img )

   mail_server = smtplib.SMTP( server )
   mail_server.sendmail( sender, receiver, msg.as_string() )

   mail_server.quit()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号