Skip to content

peterbrescia/SMTPClient.jl

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SMTPClient


2015-10-31: This package is deprecated, and does not have an active maintainer. It is not recommended for use in new projects. Commit access may be given to anyone interested in taking on reviving, maintaining, or furthering development. If you are interested, please submit a PR that updates the package.


Build Status

SMTPClient SMTPClient

A CURL based SMTP client with fairly low level API. It is useful for sending emails from within Julia code. Depends on LibCURL.jl.

##Installation

Pkg.add("SMTPClient")

The libCurl native library must be available. It is usually installed with the base system in most unix variants.

##Usage

using SMTPClient
SMTPClient.init()
o=SendOptions(blocking=true, 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\nFrom: You <[email protected]>\nTo: [email protected]\nSubject: Julia Test\n\nTest Message")
resp=send("smtp://smtp.gmail.com:587", ["<[email protected]>"], "<[email protected]>", body, o)
SMTPClient.cleanup()

##Function Reference

send(url, to-addresses, from-address, message-body, options)

send an email.

  • url should be of the form smtp://server:port.
  • to-address is a one dimensional array of Strings.
  • from-address is a String. All addresses must be enclosed in angle brackets.
  • message-body must be a RFC5322 formatted message body provided via an IO.
  • options is an object of type SendOptions. It contains authentication information, as well as the option of whether the server requires TLS.

SendOptions(; blocking=true, isSSL=false, username="", passwd="" )

Options are passed via the SendOptions constructor that takes keyword arguments. The defaults are shown above. If the username is blank, the password is not sent even if present. If blocking is set to fall, the send function is executed via a RemoteCall to the current node.

SMTPClient.init() and SMTPClient.cleanup()

These are global functions that need to be used only once per session. Data created during a single call to send is cleaned up autmatically before the function returns. Also, note that no keepalive is implemented. New connections to the SMTP server are created for each message.

About

[deprecated] Send emails from Julia

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Julia 100.0%