Skip to content

Commit 5a3650d

Browse files
Merge pull request #479 from python-fuse/automated-email-script
Email automation script
2 parents 2d76cc1 + 8889c8c commit 5a3650d

2 files changed

Lines changed: 100 additions & 0 deletions

File tree

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import smtplib
2+
from email.mime.text import MIMEText
3+
4+
def main():
5+
print("Welcome to the Email Automation Script!")
6+
7+
# Get sender's email and password
8+
sender_email = input('Enter your email: ')
9+
10+
# Security Warning
11+
print("\n** SECURITY WARNING **")
12+
print("Entering your email password directly in the script can be a security risk.")
13+
print("Consider using app passwords for Gmail or other secure authentication methods.")
14+
print("Do not share your scripts containing passwords with others.")
15+
print("Continue only if you understand and accept these risks.\n")
16+
17+
print('If you have 2-factor authentication turned on, make sure to generate an app password. \nOtherwise, enter your password.')
18+
sender_password = input('Enter the Password: ')
19+
20+
21+
22+
# Get receiver's emails
23+
receivers = input('Enter the receiver\'s emails separated by commas: ')
24+
receiver_emails = [x.strip() for x in receivers.split(',')]
25+
26+
smtp_server = "smtp.gmail.com" # SMTP server for Gmail only
27+
smtp_port = 587 # Port 587 is the secure SMTP port for Gmail
28+
29+
# Create email message
30+
message = MIMEText(input('Enter the mail body: '))
31+
message["Subject"] = input("Subject: ") if input("Enter a subject (leave empty for default): ") else "Automated Email"
32+
message["From"] = sender_email
33+
message["To"] = ", ".join(receiver_emails)
34+
35+
# Call function to send email
36+
send_auto_mail(sender_email, sender_password, receiver_emails, smtp_server, smtp_port, message)
37+
38+
def send_auto_mail(sender_email, sender_password, receiver_emails, smtp_server, smtp_port, message):
39+
try:
40+
with smtplib.SMTP(smtp_server, smtp_port) as server:
41+
server.starttls()
42+
server.login(sender_email, sender_password)
43+
44+
# Send email
45+
server.sendmail(sender_email, receiver_emails, message.as_string())
46+
47+
print("Email sent successfully!")
48+
49+
except Exception as e:
50+
print('Error sending mail:', str(e))
51+
52+
if __name__ == "__main__":
53+
main()

Automated_email/readme.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Automated Email Sender - Python Script
2+
3+
This is a Python script that facilitates the automation of sending personalized email messages or notifications to one or multiple recipients using the `smtplib` library. It is intended for use with Gmail's SMTP server.
4+
5+
## Key Features
6+
7+
- Send personalized emails to multiple recipients.
8+
- Configure sender's email, recipient emails, subject, and message.
9+
- Utilizes secure TLS encryption for email transmission.
10+
- Includes a crucial security warning about password handling.
11+
12+
## Getting Started
13+
14+
1. Clone or download this repository to your local environment.
15+
16+
2. Ensure you have Python installed on your system.
17+
18+
3. Open a terminal/command prompt and navigate to the script directory.
19+
20+
4. Run the script:
21+
```
22+
python email_automation.py
23+
```
24+
25+
5. Follow the prompts to provide necessary information such as sender email, password, recipient emails, subject, and message.
26+
27+
6.Sample test usage
28+
29+
![Screenshot (7)](https://github.com/python-fuse/Pentesting-and-Hacking-Scripts/assets/129158431/c13dbd38-e115-442c-ba54-efceee04ce95)
30+
31+
## Security Precaution
32+
33+
**Important: Entering your email password directly in the script can pose a security risk.** It is advised to generate and use app passwords, especially if you have two-factor authentication enabled. Never share scripts containing sensitive credentials. Proceed only if you comprehend and acknowledge these potential risks.
34+
35+
## Contribution
36+
37+
Contributions to this script are warmly welcomed! If you identify any bugs, potential enhancements, or wish to add features, please fork this repository and initiate pull requests.
38+
39+
## License
40+
41+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
42+
43+
---
44+
45+
This automated email script was developed by Umar Muhammad Muktar[@python-fuse].
46+
47+
For any inquiries, please contact [hauwamuktar880@gmail.com].

0 commit comments

Comments
 (0)