Skip to content

Commit 8943b95

Browse files
Create Email Automation Script.py
1 parent f5c0f0d commit 8943b95

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import smtplib
2+
from email.mime.text import MIMEText
3+
4+
sender_email = 'your_email@example.com'
5+
receiver_email = 'recipient@example.com'
6+
smtp_server = 'smtp.example.com'
7+
smtp_port = 587
8+
smtp_username = 'your_email@example.com'
9+
smtp_password = 'your_email_password'
10+
11+
message = MIMEText('Hello, this is an automated email!')
12+
message['Subject'] = 'Automated Email'
13+
message['From'] = sender_email
14+
message['To'] = receiver_email
15+
16+
try:
17+
with smtplib.SMTP(smtp_server, smtp_port) as server:
18+
server.starttls()
19+
server.login(smtp_username, smtp_password)
20+
server.sendmail(sender_email, [receiver_email], message.as_string())
21+
print("Email sent successfully!")
22+
except Exception as e:
23+
print(f"Error sending email: {e}")

0 commit comments

Comments
 (0)