Skip to content

Commit bbedf1b

Browse files
Merge pull request #459 from Abhinavcode13/patch-4
Create Email Automation Script.py
2 parents a79435a + 8943b95 commit bbedf1b

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)