Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def previewAll():
"""
Tests are only going to pass for "me" at this point.
I very much will change that in the future
"""
yag = yagmail.Connect()
mail_combinations = getCombinations(yag)
passed = 0
failed = 0
for combination in mail_combinations:
try:
yag.send(**combination)
passed += 1
# pylint: disable=broad-except
# Ignoring broad except because I just want to see all the errors
except Exception as e:
failed += 1
print(e)
print(combination)
print('{} tests passed, {} failed'.format(passed, failed))
def CLIsendMail(self):
usrEmail = input("Great! What is your e-mail address? ")
usrPass = getpass.getpass(prompt = "What is your password: ")
yag = yagmail.SMTP(usrEmail, usrPass)
content = input("Please enter the body of the e-mail: ")
cryptContent = self.encrypt(content)
sendTo = input("Who do you want to send this to? ")
subject = input("Subject line? ")
yag.send(sendTo, subject, cryptContent)
print("Message sent successfully!!!")
again = input("Send another message? (yes/no) ")
if again == 'yes' or again == 'Yes':
self.CLIsendMail()
else:
print("Goodybye!")
sys.exit(0)
[sg.Button('Send'), sg.Button('Home'), sg.Button('Exit')]]
# Show the window to the user
window = sg.Window('emailEncryptor').Layout(layout)
window2 = sg.Window('Cipher Selector').Layout(layout2)
window3 = sg.Window('Stegonagraphy encryptor').Layout(layout3)
# Send the mail
while True:
button, values = window2.Read()
if button == 'Next':
if values[0] == True:
# Determine if Caesar radio button is selected
window2.Hide()
button2, values2 = window.Read()
if button2 == 'Send':
encryptedContent = caesar.encrypt(values2[4])
yag = yagmail.SMTP(values2[0], values2[1])
yag.send(values2[2], values2[3], encryptedContent)
sg.Popup('Email sent succesfully!')
if button2 == 'Home':
window.Hide()
home()
else:
sys.exit()
elif values[1] == True:
window2.Hide()
while True:
button3, values3 = window3.Read()
if button3 == 'Send':
if values3[4] == '':
sg.Popup("Please enter a message!")
break
file = open('temp.txt', 'w')
home()
else:
sys.exit()
elif values[1] == True: #Steg has been selected
window2.Hide()
button3, values3 = window3.Read()
if button3 == 'Send':
if values3[4] == '':
sg.Popup("Please enter a message!")
break
file = open('temp.txt', 'w')
file.write(values3[4])
file.close()
encryptedImage = realSteg.encrypt('temp.txt', values3[5])
os.remove('temp.txt')
yag = yagmail.SMTP(values3[0], values3[1])
yag.send(values3[2], values3[3], 'new.png')
sg.Popup('Email sent succesfully!')
os.remove('new.png')
elif button3 == 'Home':
window3.Hide()
home()
else:
sys.exit()
elif button == 'Home':
window2.Hide()
home()
else:
sys.exit()
def Email(file=None):
"""
open email pop/stmp function and input right host、passwd.
"""
try:
yag = yagmail.SMTP(
user=config['seed_email_user'],
password=config['seed_email_pass'],
host=config['seed_email_host']
)
body = 'God is a girl'
yag.send(
to=config['receive_email_user'],
subject='Subdomains',
contents=[body, file])
print '[-] Send Email Success!!!'
except:
print '[-] Send Email Error!!!'
elif attachments == '':
attachments = []
# compose message
current_time = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
if self.config['email']['enable-all']:
statement = 'The pylinac watcher analyzed the file named or containing "{}" at {}. '
statement += 'The analysis results are in the folder "{}".'
elif self.config['email']['enable-failure']:
statement = 'The pylinac watcher analyzed the file named or containing "{}" at {} and '
statement += 'found something that failed your configuration settings.'
statement += 'The analysis results are in the folder "{}".'
statement = statement.format(name, current_time, osp.dirname(self.full_path))
# send the email
contents = [statement] + attachments
recipients = [recipient for recipient in self.config['email']['recipients']]
yagserver = yagmail.SMTP(self.config['email']['sender'], self.config['email']['sender-password'])
yagserver.send(to=recipients,
subject=self.config['email']['subject'],
contents=contents)
logger.info("An email was sent to the recipients with the results")
to_email_list = to_email_list.encode('utf8') if isinstance(to_email_list, unicode) else to_email_list
to_email_list = [email.encode('utf8') if isinstance(email, unicode) else email for email in
to_email_list] if isinstance(to_email_list, (list, tuple)) else to_email_list
cc = cc.encode('utf8') if isinstance(cc, unicode) else cc
cc = [email.encode('utf8') if isinstance(email, unicode) else email for email in cc] if isinstance(cc, (
list, tuple)) else cc
user = b'ai_public@gow.cn'
password = b'AI_public123'
host = b'smtp.exmail.qq.com'
port = b'25'
# 初始化一个SMTP客户端,并发送邮件
# yagmail.SMTP()默认使用的gmail的SMTP服务
with yagmail.SMTP(user=user, password=password, host=host, port=port)as yag:
yag.send(to=to_email_list, subject=subject, contents=contents, attachments=attachments, cc=cc, bcc=bcc)
# https://developers.google.com/gmail/api/quickstart/python
# if you want more security
# Use paid plan with https://gsuite.google.com/pricing.html
# or https://github.com/tomav/docker-mailserver
import sys
sys.path.append("..")
import yagmail
from termcolor import colored
from settings import GITHUB_TOKEN, email_author
from draft import body # use files in templates instead of this while you refer to the Rust version.
yag = yagmail.SMTP(email_author) # email_author will be youremail in youremail@email.com
subject = input("What is the subject?\n")
colored_comma = colored(',', attrs=["bold"])
to = input(f"Who will receive this email?(Use {colored_comma} to send the email for many users)\n")
colored_options = colored("(pt|en)", attrs=["bold"])
response = input(f"What language you want to use for the mail?{colored_options}\n")
resume_en = "files/cv-en.pdf"
resume_pt = "files/cv-pt.pdf"
img = "static/favicon.ico"
contents = [
body[response],
resume_pt,
def smtp(self):
if self._smtp is None:
from yagmail import SMTP
self._smtp = SMTP(self.email, **self._kwargs)
return self._smtp
def send_email_163(subject, body, file):
# 配置163发送邮件的主体账户选项
yag = yagmail.SMTP(user='xugongli2012@163.com', password='', host='smtp.163.com', port='465')
body = body
# 配置接收邮件的邮箱
yag.send(to=['982749459@qq.com'], subject=subject, contents=[body, r'%s' % file])