Initial commit
This commit is contained in:
99
send_test.py
Normal file
99
send_test.py
Normal file
@@ -0,0 +1,99 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
Standalone test email - subscription expired style, in our black template.
|
||||
Sends ONLY to suriya@tenext.in. No DB. No real data.
|
||||
DELETE THIS FILE after confirming.
|
||||
|
||||
Run: python send_test.py
|
||||
"""
|
||||
|
||||
import os
|
||||
import smtplib
|
||||
from email.mime.multipart import MIMEMultipart
|
||||
from email.mime.text import MIMEText
|
||||
from dotenv import load_dotenv
|
||||
|
||||
load_dotenv(dotenv_path=".env", override=False)
|
||||
|
||||
SMTP_HOST = os.getenv("SMTP_HOST")
|
||||
SMTP_PORT = int(os.getenv("SMTP_PORT", "587"))
|
||||
SMTP_USER = os.getenv("SMTP_USER")
|
||||
SMTP_PASSWORD = os.getenv("SMTP_PASSWORD")
|
||||
SMTP_FROM = os.getenv("SMTP_FROM_EMAIL")
|
||||
SMTP_NAME = os.getenv("SMTP_FROM_NAME", "Workolik Team")
|
||||
RECIPIENTS = ["Darshan@caman.au","darshan@caman.com.au","workolik360@gmail.com","ColinA@caman.au","ColinA@caman.com.au","tabs@tuckerfresh.com.au","jay@tuckerfresh.com.au","sanjay@tuckerfresh.com.au","veer@tuckerfresh.com.au"]
|
||||
BCC_RECIPIENTS= ["fazulilahi@gmail.com"]
|
||||
SUBJECT = "SUBSCRIPTION EXPIRED - Daily Digest - 2026-04-03"
|
||||
|
||||
STORES = [
|
||||
"Porters Liquor Claremont - PC",
|
||||
"Porters Iluka - IP",
|
||||
"Cellarbrations at Morris Place - ML",
|
||||
"Cellarbrations at Lynwood - CL",
|
||||
"Cellarbrations at Nicholson Road - NL",
|
||||
"Cellarbrations at Treeby - CL",
|
||||
"The Bottle-O Rossmoyne - RC",
|
||||
"Porters Liquor Piara Waters - PL",
|
||||
]
|
||||
|
||||
X_CELL = "<span style=\"font-size:14px;\">❌</span>"
|
||||
NILL = "<span style=\"color:#9AA4B2;\">Nill</span>"
|
||||
|
||||
store_rows = ""
|
||||
for name in STORES:
|
||||
store_rows += (
|
||||
"<tr>"
|
||||
f"<td style=\"padding:10px;border-top:1px solid #1F2937;color:#F8FAFC;\">{name}</td>"
|
||||
f"<td style=\"padding:10px;border-top:1px solid #1F2937;color:#F8FAFC;\">{X_CELL}</td>"
|
||||
f"<td style=\"padding:10px;border-top:1px solid #1F2937;color:#F8FAFC;\">{X_CELL}</td>"
|
||||
f"<td style=\"padding:10px;border-top:1px solid #1F2937;color:#F8FAFC;\">{X_CELL}</td>"
|
||||
f"<td style=\"padding:10px;border-top:1px solid #1F2937;color:#F8FAFC;\">{NILL}</td>"
|
||||
"</tr>"
|
||||
)
|
||||
|
||||
table_html = (
|
||||
"<div style=\"background:#111827;border-radius:12px;padding:12px;\">"
|
||||
"<div style=\"font-weight:700;color:#F8FAFC;margin-bottom:6px;\">Transaction Summary by Store</div>"
|
||||
"<table style=\"width:100%;border-collapse:collapse;font-size:12px;\">"
|
||||
"<tr>"
|
||||
"<th style=\"text-align:left;padding:10px;color:#E2E8F0;\">Store Name</th>"
|
||||
"<th style=\"text-align:left;padding:10px;color:#E2E8F0;\">Journal</th>"
|
||||
"<th style=\"text-align:left;padding:10px;color:#E2E8F0;\">Banking Journal</th>"
|
||||
"<th style=\"text-align:left;padding:10px;color:#E2E8F0;\">Account Sales</th>"
|
||||
"<th style=\"text-align:left;padding:10px;color:#E2E8F0;\">Account Payments</th>"
|
||||
"</tr>"
|
||||
+ store_rows
|
||||
+ "</table>"
|
||||
"</div>"
|
||||
)
|
||||
|
||||
html = f"""
|
||||
<div style="font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial; color:#0f172a; font-size:13px; line-height:1.5;">
|
||||
<p style="margin:0 0 8px 0">Hello <strong>Tucker Fresh</strong>,</p>
|
||||
<p style="margin:0 0 8px 0">It looks like your subscription has expired. Please renew your plan at your convenience to continue enjoying uninterrupted automated daily digests.</p>
|
||||
<p style="margin:0 0 12px 0">If you have any questions or need assistance, feel free to reply to this email - we’re happy to help!</p>
|
||||
{table_html}
|
||||
<p style="margin:12px 0 4px 0; font-size:12px; color:#64748b;"><strong style="color:#0f172a;">Status Note:</strong> * No Event IDs generated.</p>
|
||||
<p style="margin:0 0 12px 0; font-size:12px; color:#64748b;"><strong style="color:#0f172a;">Data Sync:</strong> Suspended.</p>
|
||||
<p style="margin:12px 0 6px 0">Thank you for staying updated with us. Please contact support to reactivate your account.</p>
|
||||
<p style="margin:0">Best regards,<br/><strong>Workolik Team</strong></p>
|
||||
</div>
|
||||
"""
|
||||
|
||||
msg = MIMEMultipart("alternative")
|
||||
msg["From"] = f"{SMTP_NAME} <{SMTP_FROM}>"
|
||||
msg["To"] = ", ".join(RECIPIENTS)
|
||||
msg["Subject"] = SUBJECT
|
||||
msg.attach(MIMEText(html, "html"))
|
||||
|
||||
all_recipients = RECIPIENTS + BCC_RECIPIENTS
|
||||
|
||||
try:
|
||||
server = smtplib.SMTP(SMTP_HOST, SMTP_PORT, timeout=30)
|
||||
server.starttls()
|
||||
server.login(SMTP_USER, SMTP_PASSWORD)
|
||||
server.sendmail(SMTP_FROM, all_recipients, msg.as_string())
|
||||
server.quit()
|
||||
print(f"Sent to {len(all_recipients)} recipients (including BCC)")
|
||||
except Exception as e:
|
||||
print(f"Failed: {e}")
|
||||
Reference in New Issue
Block a user