Skip to content

Commit

Permalink
Merge pull request #362 from nishant4500/patch-11
Browse files Browse the repository at this point in the history
Create test email.py
  • Loading branch information
suryanshsk authored Oct 21, 2024
2 parents 4ccf5a8 + 81822df commit d110a70
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions test email.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import smtplib

def send_email(subject, body, to_email):
try:

smtp_server = 'sandbox.smtp.mailtrap.io'
smtp_port = 2525 # Provided by Mailtrap
sender_email = 'yourusername' # Use Mailtrap's provided username
send_password = 'yourpassword' # Use Mailtrap's provided password

message = f'Subject: {subject}\n\n{body}'

with smtplib.SMTP(smtp_server, smtp_port) as server:
server.starttls()
server.login(sender_email, send_password)
server.sendmail(sender_email, to_email, message)

print(f"Email sent to {to_email}")

except Exception as e:
print(f"Something went wrong: {e}")

if __name__ == "__main__":
send_email("Test Email", "This is a test email body", "[email protected]")

0 comments on commit d110a70

Please sign in to comment.