-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSend_Mail_python.py
44 lines (38 loc) · 1.48 KB
/
Send_Mail_python.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
from pywebio.input import *
from pywebio.output import *
import smtplib
from email.mime.text import MIMEText
def send_mail():
''' function creat smtp session for send mail
args:send_mail,token_mail,reciv_mail,message
return:sendmail(send_mail, reciv_mail, message)'''
# creates SMTP session
sms = smtplib.SMTP('smtp.gmail.com', 587)
# start TLS for security
sms.starttls()
sender = input_group("my email".title(),[
input('enter your email please '.title(), name='my_email'),
input('enter your password or token please'.title(), name='my_pass' , type=PASSWORD)])
# sender =input("enter your email please".title())
receiver = input("send to email please".title())
mail = input_group("email message".title(),[
input('mail subject'.title(), name='subject'),
textarea('mail message'.title(), rows=3, name='message')])
msg = MIMEText(mail['message'])
msg['Subject'] = mail['subject']
msg['From'] = sender['my_email']
msg['To'] = receiver
# token_mail = sender['mypass'] # mail_pass_token
# Authentication
sms.login(sender['my_email'], sender['my_pass'])
# message to be sent
# sending the mail
sms.sendmail(sender['my_email'], receiver, msg.as_string())
# terminating the session
sms.quit()
put_text(f"send mail to {receiver} is done ...".title()).style('color: yellow; font-size: 45px')
if __name__=="__main__":
send_mail()
# nour70331@gmail.com
# tczbejrhneaenmcj
# abdoelsharef1@gmail.com