Пример #1
0
def run(arguments):
    if arguments['--config'] or (not os.path.isfile(CONF)):
        conf()
    with open(CONF, 'rb') as f:
        smtp = json.loads(f.read())
    mail = Mail(host=smtp['server'],
                username=smtp['user'],
                password=smtp['password'],
                port=int(smtp['port']),
                fromaddr=smtp['from'])
    msg = Message(arguments['--subject'],
                  fromaddr=smtp['from'],
                  body=arguments['--message'])
    to = arguments['--to']
    if to:
        msg.to = to.split(';')
    cc = arguments['--cc']
    if cc:
        msg.cc = cc.split(';')
    bcc = arguments['--bcc']
    if bcc:
        msg.bcc = bcc.split(';')
    atta = arguments['--attach']
    if atta:
        msg.attach(atta.split(';'))
    mail.send(msg)
Пример #2
0
def sendMail(to, subject, msgContext):
    pLog("Send Server Mail")
    config = ConfigParser.RawConfigParser()
    config.read('defaults.cfg')
    msg = Message(subject, fromaddr=config.get('SendAbuse', 'from'), to=to)
    if(to!=config.get('SendAbuse', 'from')):
        msg.bcc = config.get('SendAbuse', 'from')
    msg.body = msgContext
    msg.date = time.time()
    msg.charset = "utf-8"
    mail = Mail(config.get('SendAbuse', 'server'), port=config.get('SendAbuse', 'port'), username=config.get('SendAbuse', 'user'), password=config.get('SendAbuse', 'pass'),use_tls=False, use_ssl=False, debug_level=None)
    mail.send(msg)
Пример #3
0
def send_message(subject, to, body):
	mail = Mail(MAIL_SMTP_ADDRESS, port=MAIL_PORT,
	username=FROM_EMAIL, password=MAIL_PASSWORD,
			use_tls=False, use_ssl=False, debug_level=None)

	msg = Message()
	msg = Message(subject)
	msg.fromaddr = (FROM_NAME, FROM_EMAIL)
	msg.to = to

	msg.bcc = [DEV_EMAIL]
	msg.html = body

	mail.send(msg)
	return True
Пример #4
0
def sendMail(to, subject, msgContext):
    pLog("Send Server Mail")
    config = ConfigParser.RawConfigParser()
    config.read('defaults.cfg')
    msg = Message(subject, fromaddr=config.get('SendAbuse', 'from'), to=to)
    if (to != config.get('SendAbuse', 'from')):
        msg.bcc = config.get('SendAbuse', 'from')
    msg.body = msgContext
    msg.date = time.time()
    msg.charset = "utf-8"
    mail = Mail(config.get('SendAbuse', 'server'),
                port=config.get('SendAbuse', 'port'),
                username=config.get('SendAbuse', 'user'),
                password=config.get('SendAbuse', 'pass'),
                use_tls=False,
                use_ssl=False,
                debug_level=None)
    mail.send(msg)
Пример #5
0
pwrd = os.environ['GMAIL_PASS']

if __name__ == "__main__":
    with Imbox(imap, username=user, password=pwrd,
               ssl=True, ssl_context=None,
               starttls=False) as imbox:
        drafts = imbox.messages(folder="[Gmail]/Drafts")
        todays_mail = []
        for uid, msg in drafts:
            if 'schedmail' in msg.subject.lower():
                date = msg.subject.lower().split(':')[1]
                today = pendulum.now().date().isoformat()
                subject_date = pendulum.parse(date).date().isoformat()
                if subject_date == today:
                    todays_mail.append(msg)

    mail = Mail('smtp.gmail.com', port=587, username=user,
                password=pwrd, use_tls=True)

    for i in todays_mail:
        msg = Message(i.subject.split(':')[-1])
        msg.fromaddr = (i.sent_from[0]['name'], i.sent_from[0]['email'])
        msg.to = [j['email'] for j in i.sent_to]
        msg.cc = [j['email'] for j in i.cc]
        msg.bcc = [j['email'] for j in i.bcc]
        msg.body = i.body['plain'][0]
        msg.html = i.body['html'][0]
        msg.charset = 'utf-8'

        mail.send(msg)
Пример #6
0
            username=SMTP_USER,
            password=SMTP_PASS,
            fromaddr=SMTP_ADDRESS)

msg01 = Message("Hello01", to="*****@*****.**", body="hello world")

msg02 = Message("Hello02", to="*****@*****.**")
msg02.fromaddr = ('no-reply', '*****@*****.**')
msg02.body = "hello world!"

msg03 = Message("Hello03", to="*****@*****.**")
msg03.fromaddr = (u'请勿回复', '*****@*****.**')
msg03.body = u"你好世界"  # Chinese :)
msg03.html = u"<b>你好世界</b>"

msg04 = Message("Hello04", body="Hello world 04")
msg04.to = "*****@*****.**"
msg04.cc = ["*****@*****.**", "cc02@example"]
msg04.bcc = ["*****@*****.**"]

msg05 = Message("Hello05", to="*****@*****.**", body="Hello world 05")
with open("../docs/_static/sender.png") as f:
    msg05.attach_attachment("sender.png", "image/png", f.read())

msg06 = Message("Hello06", to="*****@*****.**", body="Hello world 06")
with open("test.txt") as f:
    attachment = Attachment("test.txt", "text/plain", f.read())
msg06.attach(attachment)

mail.send([msg01, msg02, msg03, msg04, msg05, msg06])
Пример #7
0
msg02 = Message("Hello02", to="*****@*****.**")
msg02.fromaddr = ('no-reply', '*****@*****.**')
msg02.body = "hello world!"


msg03 = Message("Hello03", to="*****@*****.**")
msg03.fromaddr = (u'请勿回复', '*****@*****.**')
msg03.body = u"你好世界" # Chinese :)
msg03.html = u"<b>你好世界</b>"


msg04 = Message("Hello04", body="Hello world 04")
msg04.to = "*****@*****.**"
msg04.cc = ["*****@*****.**", "cc02@example"]
msg04.bcc = ["*****@*****.**"]


msg05 = Message("Hello05", to="*****@*****.**", body="Hello world 05")
with open("../docs/_static/sender.png") as f:
    msg05.attach_attachment("sender.png", "image/png", f.read())


msg06 = Message("Hello06", to="*****@*****.**", body="Hello world 06")
with open("test.txt") as f:
    attachment = Attachment("test.txt", "text/plain", f.read())
msg06.attach(attachment)


mail.send([msg01, msg02, msg03, msg04, msg05, msg06])