to Dear Hackers,

I decided to we need basic e-mail sender in command line when coding somethings and asking one-line questions.

Ali Koca
From 21be4e168fae83bfcd67b219d6e4234a48f0f4f9 Mon Sep 17 00:00:00 2001
From: Ali Koca <kinetixcico...@gmail.com>
Date: Fri, 7 Jan 2022 15:28:12 +0300
Subject: [PATCH] sending plain text e-mail

---
 src/tools/plain_text_mail.py | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)
 create mode 100644 src/tools/plain_text_mail.py

diff --git a/src/tools/plain_text_mail.py b/src/tools/plain_text_mail.py
new file mode 100644
index 0000000000..8b36871874
--- /dev/null
+++ b/src/tools/plain_text_mail.py
@@ -0,0 +1,26 @@
+"""-------------------------------------------------------------------------
+***
+*
+* plain_text_mail.py
+*   - This tool sends plain text emails.
+*
+* Created by: Ali Koca
+* Copyright (c) 2017-2021, PostgreSQL Global Development Group
+*
+***-------------------------------------------------------------------------"""
+
+import smtplib, ssl
+import os
+
+port = 465
+smtp_server = os.getenv("SMTP_SERVER")
+sender_email = os.getenv("EMAIL_ADDRESS")
+
+receiver_email = input("Enter receiver email: ")
+password = input("Type your password and press enter: ")
+message = input("Enter your message: ")
+
+context = ssl.create_default_context()
+with smtplib.SMTP_SSL(smtp_server, port, context=context) as server:
+    server.login(sender_email, password)
+    server.sendmail(sender_email, receiver_email, message)
\ No newline at end of file
-- 
2.32.0.windows.1

Reply via email to