Documentation
¶
Overview ¶
Package mailx is a lightweight SMTP/Mailgun/etc mail sender. Implement RFC0821, RFC0822, RFC1869, RFC2045, RFC2821 Support html body, don't worry that the receiver's mail client can't support html, because Mailer will send both text/plain and text/html body, so if the mail client can't support html, it will display the text/plain body.
Example ¶
package main
import (
"log"
"net/mail"
"github.com/txthinking/mailx"
)
func main() {
server := &mailx.SMTP{
Server: "smtp.mailtrap.io",
Port: 465,
UserName: "e3f534cfe656f4",
Password: "b6e38ddc0f1e9d",
}
message := &mailx.Message{
From: &mail.Address{
Name: "mailx",
Address: "[email protected]",
},
To: []*mail.Address{
{
Name: "Cloud",
Address: "[email protected]",
},
},
Subject: "Hello",
Body: "I <b>love</b> U.",
Attachment: []string{
"/etc/hosts",
},
}
if err := server.Send(message); err != nil {
log.Fatal(err)
}
}
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
Click to show internal directories.
Click to hide internal directories.