Created
June 14, 2024 06:57
-
-
Save OshekharO/b98b57fda82b43499436c5f72f84b545 to your computer and use it in GitHub Desktop.
Python script that you can use to send emails to multiple recipients using Gmail SMTP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import smtplib | |
from email.mime.text import MIMEText | |
# Replace these with your details | |
sender_email = "[email protected]" | |
sender_password = "your_password" | |
recipient_emails = ["[email protected]", "[email protected]", "[email protected]"] | |
subject = "Human Resource Executive Position - [Your Name]" # Personalized subject line | |
# Body content with placeholder for hiring manager name | |
body_template = """Dear [Hiring Manager name], | |
I am writing to express my keen interest in the Human Resource Executive position at Reverr, as advertised on [Platform where you saw the job posting]. | |
As a final-year Bachelor of Commerce in Finance student with a 2-month HR internship experience, I possess a strong foundation in HR principles and practical skills in candidate shortlisting, interviewing, IT recruitment, job posting, and IT support. I am proficient in MS Office Suite (Word, Excel, PowerPoint), which enables me to efficiently manage HR tasks. | |
Thanks, | |
[Your Name]""" | |
for recipient in recipient_emails: | |
# Fill in hiring manager name (if you know it) | |
body = body_template.replace("[Hiring Manager name]", "Hiring Manager" if not recipient_specific_name else recipient_specific_name) | |
# Create message object with text content | |
message = MIMEText(body, "plain") | |
message["Subject"] = subject | |
message["From"] = sender_email | |
message["To"] = recipient | |
# Connect to Gmail's SMTP server using secure SSL connection | |
server = smtplib.SMTP_SSL("smtp.gmail.com", 465) | |
server.login(sender_email, sender_password) | |
# Send email | |
server.sendmail(sender_email, [recipient], message.as_string()) | |
# Close connection | |
server.quit() | |
print(f"Email sent successfully to {recipient}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment