#!/usr/bin/env python

"Test program to send mail to recipients."
import sys; sys.path.append('../../../') # show python where the modules are

import web.mail
testAddr = raw_input('Email address 1 to recieve tests (will receive 6 emails): ')
testAddr2 = raw_input('Email address 2 to recieve tests (will receive 2 emails): ')
if raw_input('Run the 6 SMTP tests:  [y/n] ') == 'y':
    smtp = raw_input('SMTP server address: ')
    print "Running SMTP Test...."
    counter = 1
    for blind in [True, False]:
        for to in [testAddr, [testAddr], [testAddr, testAddr2]]:
            web.mail.send(
                msg="Hello User!\n\nBlind: " + str(blind),
                to=to,
                reply=web.mail.buildReply('web.mail Test',testAddr),
                subject="SMTP Test "+ str(counter),
                smtp=smtp,
                blind=blind,
                method='smtp'
            )
            print "Sent message %s."%counter
            counter += 1
    print "Done... check your mail!\n"

if raw_input('Run the 6 sendmail tests: [y/n] ') == 'y':
    sendmail = raw_input("Sendmail Path (usually /usr/lib/sendmail): ")
    print "Running Sendmail Test...."
    counter = 1
    for blind in [True, False]:
        for to in [testAddr, [testAddr], [testAddr, testAddr2]]:
            web.mail.send(
                msg="Hello User!\n\nBlind: " + str(blind),
                to=to,
                reply=web.mail.buildReply('web.mail Test',testAddr),
                subject="Sendmail Test "+ str(counter),
                sendmail=sendmail,
                blind=blind,
                method='sendmail'
            )
            print "Sent message %s."%counter
            counter += 1
    print "Done... check your mail!"
