Mailer API

Mailer API 提供了使用 SMTP 發送郵件更高階的呼叫方式,底層封裝了原生的 SmtpClientMailMessage ...等類別

Super simple to use

以下示範使用 Gmail 提供的 SMTP 服務發送郵件

示範:

string SMTP_HOST = "smtp.gmail.com";        // SMTP 信箱位置
string MAIL_ACT = "[email protected]";  // 登入帳號
string MAIL_PWD = "...";                    // 登入密碼 (沒有密碼可給空字串)
int MAIL_PORT = 587;                        // 登入埠號
bool MAIL_SSL = true;                       // 是否使用 SSL 加密連線

Mailer m = new Mailer(SMTP_HOST, MAIL_ACT, MAIL_PWD, MAIL_PORT, MAIL_SSL);

string TO = "[email protected]";                 // 寄給誰,多人請用逗號隔開
string SUBJECT = "This is a test mail";              // 主旨
string BODY = "<h1>Test Mail by ZapLib Mailer</h1>"; // 內容

m.send(TO, SUBJECT, BODY);

輸出:

Mailer API

Mail 的內容預設支援 HTML 內容

results matching ""

    No results matching ""