-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
30 lines (27 loc) · 1.03 KB
/
main.py
File metadata and controls
30 lines (27 loc) · 1.03 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
import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
try:
msg = MIMEMultipart()
msg.set_unixfrom('author')
msg['From'] = '[email protected]'
msg['To'] = '[email protected]'
msg['Subject'] = 'Jinhe mera dil luteyaa'
message = 'OHHOOO'
msg.attach(MIMEText(message))
# Connect to the server
mailserver = smtplib.SMTP_SSL('smtpout.secureserver.net', 465)
mailserver.ehlo() # Say hello to the server
# Login to the server
mailserver.login('[email protected]', 'godaddypassword')
# Send the email
mailserver.sendmail('[email protected]', '[email protected]', msg.as_string())
# Disconnect from the server
mailserver.quit()
print("Email sent successfully!")
except smtplib.SMTPServerDisconnected as e:
print(f"SMTPServerDisconnected: {e}")
except smtplib.SMTPAuthenticationError as e:
print(f"SMTPAuthenticationError: {e}")
except Exception as e:
print(f"An error occurred: {e}")