def send(): """ Sends an test e-mail using mailtools package 'mailSender' module :return: None """ if not mailconfig.smtpuser: sender = MailSender(tracesize=5000) else: sender = MailSenderAuthConsole(tracesize=5000) # send the e-mail sender.sendMessage(From=mailconfig.myaddress, To=[mailconfig.myaddress], Subj='testing mailtools package', extrahdrs=[('X-Mailer', 'mailtools')], bodytext='Here is my source code\n', attaches=['selftest.py'], )
#!/usr/bin/python3 import sys import mailconfig sys.path.append('..') print('config:', mailconfig.__file__) # from mailFetcher import MailFetcherConsole # from mailParser import MailParser # from mailSender import MailSender, MailSenderAuthConsole from mailtools import (MailFetcherConsole, MailSender, MailSenderAuthConsole, MailParser) if not mailconfig.smtpusername: sender = MailSender() else: sender = MailSenderAuthConsole() sender.sendMessage(From=mailconfig.myaddress, To=[mailconfig.recevieaddr], Subj='testing mailtools package', extrahdrs=[('X-Mailer', 'mailtools')], bodytext='Here is my source code\n', attaches=['selftest.py']) fetcher = MailFetcherConsole() def status(*args): print(args)
# import os # sys.path.append(os.path.abspath(os.getcwd())) # print() # клиентские настройки (переменная localserver определяет какой модуль будет загружен - # с локальными или удаленными настройками конфигурации) # localserver = True # mailconfig = __import__('maillocal') if localserver else __import__('mailconfig') from resolvingConfig import mailconfig print('config:', mailconfig.__file__) # получить из __init__ from mailtools import (MailFetcherConsole, MailSender, MailSenderAuthConsole, MailParser) if not mailconfig.smtpuser: sender = MailSender(tracesize=5000) else: sender = MailSenderAuthConsole(tracesize=5000) sender.sendMessage( From=mailconfig.myaddress, To=[mailconfig.myaddress], Subj='testing mailtools package: new resolvingConfig', extrahdrs=[('X-Mailer', 'mailtools')], bodytext='Here is my source code\n', attaches=['getone.py'], ) # bodytextEncoding = 'utf-8', # дополнительные тесты # attachesEncoding = ['latin-1'], # проверка текста заголовков # attaches = ['monkeys.jpg'], # проверка Base64 # to = 'i18n addr list...', # тест заголовков mime/unicode
# e.g. 13-26 import sys sys.path.append('..') import mailconfig print('config:', mailconfig.__file__) from mailtools import (MailFetcherConsole, MailSender, MailSenderAuthConsole, MailParser) if not mailconfig.smtpuser: sender = MailSender(tracesize=5000) else: sender = MailSenderAuthConsole() sender.sendMessage(From=mailconfig.myaddress, To=[mailconfig.myaddress], Subj='testing mailtools package', extrahdrs=[('X-Mailer', 'mailtools')], bodytext='Here is my source code\n', attaches=['selftest.py']) fetcher = MailFetcherConsole() def status(*args): print(args) hdrs, sizes, loadedall = fetcher.downloadAllHeaders(status) for num, hdr in enumerate(hdrs[:5]): print(hdr) if input('load mail?') in ['Y', 'y']: print(fetcher.downloadMessage(num+1).rstrip(), '\n', '-'*70)