Giter Site home page Giter Site logo

pat's Introduction

 _
|_) _ _|_
|  (_| |_

    -- the only SMTP postman!

pat is an easy to use SMTP client for Erlang. You only need to know two functions:

  • pat:connect/2, which takes an SMTP relay, a {Host, Port} pair and a list of SMTP options, listed bellow and returns an SMTP connection.
  • pat:send/2, which sends a given email via an SMTP connection.

Here's a quick example:

(pat@postoffice)1> Opts = [{user, <<"pat">>}, {password, <<"postman">>}],
(pat@postoffice)2> Conn = pat:connect({<<"smtp.yandex.ru">>, 25}, Opts),
(pat@postoffice)3> rr("include/*").
(pat@postoffice)4> Email = #email{sender= <<"[email protected]">>,
(pat@postoffice)4>                recipients=[<<"[email protected]">>],
(pat@postoffice)4>                message= <<"Hello world!">>}.
(pat@postoffice)5> pat:send(Conn, Email).
{ok,<<"2.0.0 Ok: queued on smtp13.mail.yandex.net as mM6eOXwj-mM642Fvi">>}

As the name suggest, all connection options are optional. Here's a list of them:

| Option                        | Description                                     |
|-------------------------------+-------------------------------------------------|
| {ssl, true | false}           | Use SSL for connection.                         |
| {tls, never | always | maybe} | Start a TLS session, after connecting via an    |
|                               | unsecure socket, passing 'maybe' means: use TLS |
|                               | only if the relay supports STARTTLS command.    |
| {user, binary()}              | SMTP auth. username.                            |
| {password, binary()}          | SMTP auth. password.                            |
| {timeout, timeout()}          | A timeout in *seconds* for the underlying       |
|                               | gen_server.                                     |

pat's People

Contributors

hairyhum avatar superbobry avatar tnt-dev avatar

Watchers

 avatar  avatar

Forkers

skript

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.