예제 #1
0
def sendMail(sender, recipients, subject, html_body, attachments=None, images=None, text_message=None, reply_to=''):
    try:
        msgRoot = createMail(sender, recipients, subject, html_body, attachments, images, text_message, reply_to)        
        
        # Send the email (this example assumes SMTP authentication is required)
        #smtp = smtplib.SMTP()
        #smtp.connect('localhost', 587)
        #smtp.login('postman', 'password')
        #smtp.sendmail(sender, recipients, msgRoot.toMIMEMultipart().as_string())
        #smtp.quit()
        
        #New smtp relay
        import smtp_relay
        smtp_relay.sendMail(sender, recipients, msgRoot)
        logSentMail(recipients, subject)
    except:
        logError('Sending mail failed. Recipients=' + str(recipients) + ', subject=' + subject +  ' Error:' + str(sys.exc_info()[0]) + ', ' + str(sys.exc_info()[1]))
예제 #2
0
 def testRelay(self):
     #New smtp relay\
     import mailman
     msgRoot = mailman.createMail('Jobhunt.in<*****@*****.**>', ['*****@*****.**'], 'This is a unit test', '<div><h1>Hello, World</h1><p>This is a unit test.</p></div>', 
         attachments=None, images=None, text_message=None, reply_to='')
     smtp_relay.sendMail('Jobhunt.in<*****@*****.**>', ['*****@*****.**'], msgRoot)