Send mails with MailOut
Zuletzt aktualisiert am
Prerequisites
Section titled “Prerequisites”- You have a verified sending domain with at least one authorized sender: Create, setup, and manage sending domains
Send mails
Section titled “Send mails”To send mails with MailOut you can use every SMTP-compatible client, that is capable of PLAIN-auth.
SERVER="<your-smtp-endpoint>" \PORT=25 \SMTP_USERNAME="<your-username>" \SMTP_PASSWORD="<your-password>" \SENDER="noreply@<your-domain>" \RECIPIENT="<recipient>@aboutmy.email" \swaks \--to $RECIPIENT \--from $SENDER \--server $SERVER \--port $PORT \--auth plain \--auth-user $SMTP_USERNAME \--auth-password $SMTP_PASSWORD \--tlsimport osimport smtplibfrom email.mime.text import MIMEText
SERVER = os.environ.get("SERVER", "<your-smtp-endpoint>")PORT = int(os.environ.get("PORT", 25))SMTP_USERNAME = os.environ.get("SMTP_USERNAME", "<your-username>")SMTP_PASSWORD = os.environ.get("SMTP_PASSWORD", "<your-password>")SENDER = os.environ.get("SENDER", "noreply@<your-domain>")RECIPIENT = os.environ.get("RECIPIENT", "<recipient>@aboutmy.email")
msg = MIMEText("This is a test message.")msg["Subject"] = "SMTP Test"msg["From"] = SENDERmsg["To"] = RECIPIENT
with smtplib.SMTP(SERVER, PORT) as smtp: smtp.set_debuglevel(1) smtp.ehlo() smtp.starttls() smtp.ehlo() smtp.login(SMTP_USERNAME, SMTP_PASSWORD) smtp.sendmail(SENDER, [RECIPIENT], msg.as_string())
print("Mail queued successfully.")package main
import ("fmt""log""net/smtp""os")
func getEnv(key, fallback string) string {if v := os.Getenv(key); v != "" {return v}return fallback}
func main() {server := getEnv("SERVER", "<your-smtp-endpoint>")port := getEnv("PORT", "25")username := getEnv("SMTP_USERNAME", "<your-username>")password := getEnv("SMTP_PASSWORD", "<your-password>")sender := getEnv("SENDER", "noreply@<your-domain>")recipient := getEnv("RECIPIENT", "<recipient>@aboutmy.email")
addr := fmt.Sprintf("%s:%s", server, port)
auth := smtp.PlainAuth("", username, password, server)
msg := []byte("To: " + recipient + "\r\n" + "From: " + sender + "\r\n" + "Subject: SMTP Test\r\n" + "\r\n" + "This is a test message.\r\n")
err := smtp.SendMail(addr, auth, sender, []string{recipient}, msg) if err != nil { log.Fatal(err) }
fmt.Println("Mail queued successfully.")
}