How to use get_email method in mailosaur-python

Best Python code snippet using mailosaur-python_python

test_email.py

Source:test_email.py Github

copy

Full Screen

...15##############################################################################16# FIXTURES17##############################################################################18@pytest.fixture()19def get_email(mocker):20 """Return a valid Email object."""21 config_mock = mocker.patch.object(messages.email_, 'check_config_file')22 e = Email(from_='me@here.com', to='you@there.com',23 server='smtp.gmail.com', port=465, auth='password',24 cc='someone@there.com', bcc='them@there.com',25 subject='subject', body='message', attachments=['file1', 'file2'],26 profile='myName', save=False)27 e.from_ = 'me@here.com'28 e.server = 'smtp.gmail.com'29 e.port = 46530 e.auth = 'password'31 return e32##############################################################################33# TESTS: Email.__init__...

Full Screen

Full Screen

Email.py

Source:Email.py Github

copy

Full Screen

...8path = getpathInfo.get_Path()9report_path = os.path.join(path, 'result')10def send_mail():11 # 邮箱的服务地址12 gserver = read_conf.get_email('gserver') # 从配置文件中读取,邮件主题13 gport = int(read_conf.get_email('gport'))14 username = read_conf.get_email('username')15 password = read_conf.get_email('password')16 filename = os.path.join(report_path, "report.html")17 f = open(filename, 'rb')18 mail_body = f.read()19 f.close()20 # 组装邮件内容和标题,中文需参数‘utf-8’,单字节字符不需要21 msg = MIMEMultipart()22 # 邮件正文23 msg.attach(MIMEText(mail_body, _subtype='html', _charset='utf-8'))24 # 添加附件25 att1 = MIMEText(open(filename, 'rb').read(), 'base64', 'utf-8')26 att1['Content-Type'] = 'application/octet-stream'27 att1["Content-Disposition"] = 'attachment; filename="%s"' % 'report.html'28 msg.attach(att1)29 msg['from'] = read_conf.get_email('mailfrom')30 msg['to'] = ','.join(read_conf.get_email('mailto').split(','))31 # 抄送32 msg['Cc'] = read_conf.get_email('mailcc')33 msg['Reply-To'] = read_conf.get_email('mailfrom')34 msg['Subject'] = read_conf.get_email('subject')35 try:36 smtp = smtplib.SMTP(gserver, gport)37 smtp.starttls()38 smtp.login(username, password)39 smtp.sendmail(read_conf.get_email('mailfrom'), read_conf.get_email('mailto').split(','), msg.as_string())40 smtp.quit()41 smtp.close()42 print("邮件发送成功")43 except Exception as err:44 print("Send mail failed. ", err)45if __name__ == "__main__":...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run mailosaur-python automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful