2.2 KiB
2.2 KiB
Direct SMTP send (without Himalaya)
Use this when composing and sending a single email without installing the Himalaya CLI.
Prerequisites
- A password file at
/root/.config/himalaya/<account>.passwith the plaintext password - SMTP server host and port (typically 587 for STARTTLS, 465 for SSL)
Pattern
import smtplib
from email.mime.text import MIMEText
pw = open("/root/.config/himalaya/<account>.pass").read().strip()
msg = MIMEText("Body text here.")
msg["From"] = "sender@domain.com"
msg["To"] = "recipient@example.com"
msg["Subject"] = "Subject line"
with smtplib.SMTP("mail.domain.com", 587) as s:
s.starttls()
s.login("sender@domain.com", pw)
s.send_message(msg)
Notes
- Adjust host, port, account, and password file path per deployment.
- Port 587 with
starttls()is the most common; useSMTP_SSL(host, 465)for direct SSL. - The password file is typically mode
0600— the one created byhimalaya account configure. - For multipart or HTML messages, use
email.mime.multipart.MIMEMultipartandemail.mime.text.MIMETextwith_subtype='html'. - For attachments, use
MIMEBaseoremail.mime.application.MIMEApplication.
Email-to-SMS gateway sending
Carrier SMS gateways convert an email to a text message. Keep the body short (SMS length, ~160 characters recommended for full delivery).
T-Mobile: NUMBER@tmomail.net
Verizon: NUMBER@vtext.com
AT&T: NUMBER@txt.att.net
Sprint: NUMBER@messaging.sprintpcs.com
Sending is identical to regular SMTP — set To to the SMS gateway address. Plain MIMEText with a short body works best.
Daily recurring SMS via email
For a scheduled daily humorous/obnoxious message sent to a phone number:
- Create a cron job prompt that generates unique subject and body each day. Include the recipient's name for personalization.
- The prompt must forbid spam trigger words (free, limited time, act now, etc.) to avoid SMS gateway filtering.
- Use
deliver='origin'so confirmation arrives in your chat. - Test with a one-off SMTP send before scheduling so the user can verify delivery.
The cron job handles content generation — no static script needed for the creative part.