smtp-mail: Simple email sending via SMTP

[ bsd3, library, network ] [ Propose Tags ]

This packages provides a simple interface for mail over SMTP. PLease see the README for more information.


[Skip to Readme]

Downloads

Note: This package has metadata revisions in the cabal description newer than included in the tarball. To unpack the package including the revisions, use 'cabal get'.

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

Versions [RSS] 0.1.0.0, 0.1.1.0, 0.1.2.0, 0.1.3.0, 0.1.4.0, 0.1.4.1, 0.1.4.2, 0.1.4.3, 0.1.4.4, 0.1.4.5, 0.1.4.6, 0.2.0.0, 0.2.0.1, 0.3.0.0, 0.4.0.0
Change log CHANGELOG.md
Dependencies array, base (>=4.11 && <5), base16-bytestring, base64-bytestring, bytestring, connection, cryptohash, filepath, mime-mail (>=0.5 && <0.6), network, network-bsd, text [details]
License BSD-3-Clause
Author Jason Hickner, Matt Parsons
Maintainer parsonsmatt@gmail.com
Revised Revision 1 made by phadej at 2019-06-29T11:16:43Z
Category Network
Home page http://github.com/jhickner/smtp-mail
Source repo head: git clone git@github.com:jhickner/smtp-mail.git
Uploaded by parsonsmatt at 2019-06-19T16:41:06Z
Distributions Debian:0.3.0.0, NixOS:0.4.0.0, Stackage:0.4.0.0
Reverse Dependencies 3 direct, 0 indirect [details]
Downloads 15098 total (151 in the last 30 days)
Rating 2.25 (votes: 4) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2019-06-19 [all 1 reports]

Readme for smtp-mail-0.2.0.0

[back to package description]

SMTP-MAIL

Making it easy to send SMTP emails from Haskell.

cabal install smtp-mail

Sending with an SMTP server

{-# LANGUAGE OverloadedStrings #-}

import Network.Mail.SMTP

from       = Address Nothing "email@domain.com"
to         = [Address (Just "Jason Hickner") "email@domain.com"]
cc         = []
bcc        = []
subject    = "email subject"
body       = plainTextPart "email body"
html       = htmlPart "<h1>HTML</h1>"

mail = simpleMail from to cc bcc subject [body, html]

main = sendMail host mail

or with an attachment:

main = do
  attachment <- filePart "application/octet-stream" "path/to/attachment.zip"
  let mail = simpleMail from to cc bcc subject [body, html, attachment]
  sendMail host mail

or, with authentication:

main = sendMailWithLogin host user pass mail

Note: sendMail' and sendMailWithLogin' variations are also provided if you want to specify a port as well as a hostname.

Sending with sendmail

If you'd like to use sendmail, the sendmail interface from Network.Mail.Mime is reexported as well:

-- send via the default sendmail executable with default options
renderSendMail mail

-- send via the specified executable with specified options
renderSendMailCustom filepath [opts] mail

For more complicated scenarios or for adding attachments or CC/BCC addresses you can import Network.Mail.Mime and construct Mail objects manually.

Thanks

This library is based on code from HaskellNet, which appears to be no longer maintained. I've cleaned up the error handling, added some API functions to make common operations easier, and switched to ByteStrings where applicable.