Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create test email.py #362

Merged
merged 1 commit into from
Oct 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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]")