簡體   English   中英

如何使用 lua 編程語言發送 email?

[英]how to send email using lua programming language?

有人可以詳細解釋如何使用 lua 發送 email,並請分享一個模板。

使用 gmail 帳戶發送郵件是否應該遵循相同的程序? 我在 windows 10 並使用 lua 5.1。

場景:我有一個 lua function 我需要從那里向少數用戶發送郵件。 實現這一點的任何幫助都會有所幫助。 謝謝你。

來自: http://w3.impa.br/~diego/software/luasocket/smtp.html

 smtp.send{ from = string, rcpt = string or string-table, source = LTN12 source, [user = string,] [password = string,] [server = string,] [port = number,] [domain = string,] [step = LTN12 pump step,] [create = function] }

這描述了 function smpt.send,它將單個表作為參數。 方括號中的字段是可選的。 閱讀文檔了解詳細信息。

以下示例顯示如何發送 email。 請注意 smtp.send 的參數的表字段如何填充值。 您必須為您的用例更改這些值。 不知道有什么不清楚的地方。

如果你因為缺乏必要的 Lua 知識而無法理解它,我建議你做一個初學者教程並閱讀 Lua 參考手冊和 Lua 中的編程

-- load the smtp support local smtp = require("socket.smtp") -- Connects to server "localhost" and sends a message to users -- "fulano@example.com", "beltrano@example.com", -- and "sicrano@example.com". -- Note that "fulano" is the primary recipient, "beltrano" receives a -- carbon copy and neither of them knows that "sicrano" received a blind -- carbon copy of the message. from = "<luasocket@example.com>" rcpt = { "<fulano@example.com>", "<beltrano@example.com>", "<sicrano@example.com>" } mesgt = { headers = { to = "Fulano da Silva <fulano@example.com>", cc = '"Beltrano F. Nunes" <beltrano@example.com>', subject = "My first message" }, body = "I hope this works. If it does, I can send you another 1000 copies." } r, e = smtp.send{ from = from, rcpt = rcpt, source = smtp.message(mesgt) }

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM