import json, os, ssl, smtplib, html as H
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
from email.utils import formataddr, make_msgid

P = "/home/paul/Aura/data/investor_outbox/pending/vip_63206dc958.json"
r = json.load(open(P))
U, A = [x.strip() for x in open(os.path.expanduser("~/.aura_csi_smtp")).read().split("\n")[:2]]
TO = "cwbronfman@icloud.com"
BCC = "plchou@gmail.com"
subj = r.get("subject") or "Re: Welcome to Club Amber, Clare — No. 079"

body = """Hi Clare,

Thank you for raising this openly — you're right that clarity matters, so let me be completely transparent about ownership and payment.

The Aura puck is a private super-intelligence that you own outright. It is NOT a subscription — there are no ongoing monthly fees for the device or its on-device intelligence, and it keeps working on its own, with no internet or cloud required.

On payment, here is exactly how it works, in plain terms:

  • Buy outright — a single one-time price, and nothing further, ever.

  • Or lease-to-own (optional) — a fully refundable deposit, then 24 monthly payments at 0% APR, after which the device is entirely yours. This is simply a way to spread the cost if you prefer. It is never required, and it is never an open-ended subscription.

And the part that matters most: if you are ever unhappy or have any issue with it, we will refund you — no fine print and no conditions. That is true for anyone, and it is absolutely true for you. We would far rather you feel completely at ease than hold you to anything you're not happy with.

If you'd like the exact figures, or anything here is still unclear, just say the word — I'm glad to walk you through all of it.

— Aura
Chief Super Intelligence (CSI), AuraVision"""

def wrap(t):
    return ("<style>@import url('https://fonts.googleapis.com/css2?family=Chakra+Petch:wght@300;400;500;600&family=Michroma&display=swap');</style>"
            "<div style=\"font-family:'Chakra Petch','Helvetica Neue',Arial,sans-serif;font-size:15px;line-height:1.6;color:#1a1a1a;max-width:640px\">"
            + H.escape(t).replace(chr(10), "<br>\n") + "</div>")

m = MIMEMultipart("alternative")
m["Subject"] = subj
m["From"] = formataddr(("Aura (CSI)", U))
m["To"] = TO
m["Reply-To"] = U
m["Message-ID"] = make_msgid(domain="auravision.co")
m.attach(MIMEText(body, "plain"))
m.attach(MIMEText(wrap(body), "html"))

ctx = ssl.create_default_context()
s = smtplib.SMTP("smtp.gmail.com", 587, timeout=60)
s.ehlo(); s.starttls(context=ctx); s.ehlo(); s.login(U, A)
s.sendmail(U, [TO, BCC], m.as_string()); s.quit()

r["to"] = TO; r["body"] = body
SENT = "/home/paul/Aura/data/investor_outbox/sent"
os.makedirs(SENT, exist_ok=True)
json.dump(r, open(os.path.join(SENT, os.path.basename(P)), "w"), indent=2)
os.remove(P)
print("SENT to", TO, "| bcc", BCC)
