-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmail.py
More file actions
53 lines (43 loc) · 1.51 KB
/
mail.py
File metadata and controls
53 lines (43 loc) · 1.51 KB
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
45
46
47
48
49
50
51
52
53
import tkinter as tk
import smtplib
def send_email():
sender_email = email_entry.get()
sender_password = password_entry.get()
recipient_email = recipient_entry.get()
message = message_entry.get("1.0", "end")
try:
with smtplib.SMTP_SSL('smtp.gmail.com', 465) as smtp:
smtp.login(sender_email, sender_password)
smtp.sendmail(sender_email, recipient_email, message)
status_label.config(text="Email sent successfully!", fg="green")
except Exception as e:
status_label.config(text=f"Error: {e}", fg="red")
root = tk.Tk()
root.title("Mail Application")
# Sender's email address
email_label = tk.Label(root, text="Email address:")
email_label.pack()
email_entry = tk.Entry(root, width=50)
email_entry.pack()
# Sender's email password
password_label = tk.Label(root, text="Email password:")
password_label.pack()
password_entry = tk.Entry(root, width=50, show="*")
password_entry.pack()
# Recipient's email address
recipient_label = tk.Label(root, text="Recipient address:")
recipient_label.pack()
recipient_entry = tk.Entry(root, width=50)
recipient_entry.pack()
# Email message
message_label = tk.Label(root, text="Message:")
message_label.pack()
message_entry = tk.Text(root, width=50, height=10)
message_entry.pack()
# Send button
send_button = tk.Button(root, text="Send", command=send_email)
send_button.pack()
# Status label
status_label = tk.Label(root, text="")
status_label.pack()
root.mainloop()