A CURL based SMTP client with fairly low level API. It is useful for sending emails from within Julia code. Depends on LibCURL.jl.
SMTPClient requires Julia 0.7 or higher.
Pkg.add("SMTPClient")The libCurl native library must be available. It is usually installed with the base system in most Unix variants.
using SMTPClient
opt = SendOptions(
isSSL = true,
username = "[email protected]",
passwd = "yourgmailpassword")
#Provide the message body as RFC5322 within an IO
body = IOBuffer(
"Date: Fri, 18 Oct 2013 21:44:29 +0100\r\n" *
"From: You <[email protected]>\r\n" *
"To: [email protected]\r\n" *
"Subject: Julia Test\r\n" *
"\r\n" *
"Test Message\r\n")
url = "smtps://smtp.gmail.com:465"
rcpt = ["<[email protected]>", "<[email protected]>"]
from = "<[email protected]>"
resp = send(url, rcpt, from, body, opt)-
Sending from file
IOStreamis supported:body = open("/path/to/mail")
Due to the security policy of Gmail, you need to "allow less secure apps into your account":
send(url, to-addresses, from-address, message-body, options)Send an email.
urlshould be of the formsmtp://server:portorsmtps://....to-addressis a vector ofString.from-addressis aString. All addresses must be enclosed in angle brackets.message-bodymust be a RFC5322 formatted message body provided via anIO.optionsis an object of typeSendOptions. It contains authentication information, as well as the option of whether the server requires TLS.
SendOptions(; isSSL = false, verbose = false, username = "", passwd = "")Options are passed via the SendOptions constructor that takes keyword arguments.
The defaults are shown above.
verbose: enablelibcurlverbose mode or not.- If the
usernameis blank, thepasswdis not sent even if present.
Note that no keepalive is implemented. New connections to the SMTP server are created for each message.