<html>
  <head>
    <meta content="text/html; charset=windows-1252"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    I've attached 4 files that together form a remarkably simple email
    sender:<br>
    <br>
    smtp.erl - a very simple SMTP protocol that happily talks to GMail
    (you fill in your account details in the smtp_info record)<br>
    smtp.hrl - container for the smtp_info record<br>
    mail_sender.erl - not really needed, but an equally simple gen
    server that provides fire and forget access to smtp.erl<br>
    i_convert.erl - utility data conversion routines<br>
    <br>
    It's one of the first things I ever wrote in Erlang so it's not
    pretty, but it has been in production for over a year and does
    appear to "just work" (no warranties, feel free to make whatever
    changes you want, please don't sue me...).  <br>
    <br>
    Backoff etc (not sending too many emails in too short a time) we
    have always implemented higher up the food chain - we've functions
    with names like "maybe_send_email" that do simple checks as to
    whether we are needlessly filling inboxes with support messages. 
    Those functions are just a few lines long and in our case are
    tightly coupled to the business logic that requires the email to be
    sent so we've never seen the point in trying to make that generic.<br>
    <br>
    Feel free to have a play - it should be trivial to get going, but do
    drop me an email if you have any questions.  If you find it useful I
    might even put it up as a simple github project with docs (surely
    not) and an example or two...<br>
    <br>
    Here's how you fill in the record (for GMail).<br>
    <br>
    <tt>#smtp_info{<br>
                   name = whatever_you_want, %% The name (atom) of the
      gen_server (if you use mail_sender.erl)<br>
                   from = <<<a class="moz-txt-link-rfc2396E" href="mailto:your_account@gmail.com">"your_account@gmail.com"</a>>>, <br>
                   username = <<<a class="moz-txt-link-rfc2396E" href="mailto:your_account@gmail.com">"your_account@gmail.com"</a>>>,
      <br>
                   password = <<"somev3rysecretthing">>, <br>
                   server = <<"smtp.gmail.com">>,<br>
                   port = 465}.</tt><br>
    <br>
    To send an email (directly - the gen_server is self explanatory) you
    <br>
    <br>
    <tt>send_mail(SmtpInfo, <br>
                To, %% <<<a class="moz-txt-link-rfc2396E" href="mailto:erlang-questions@erlang.org">"erlang-questions@erlang.org"</a>>><br>
                ReplyTo, %% Binary - the "from" in the email - should
      really be smtp_info.from<br>
                Subject, %% <br>
                Body, <br>
                Attachments, %% List of attachments to send with the
      email,<br>
                Type %% text or html).<br>
    </tt><br>
    Read the code - it's simple enough to be documentation for now ;)<br>
    <br>
    Adrian<br>
    <small><b>Dr Adrian Roe<br>
        Director<br>
        id3as</b></small><br>
    <br>
    <div class="moz-cite-prefix">On 19/07/12 09:55, Andrzej Sliwa wrote:<br>
    </div>
    <blockquote
      cite="mid:23F44D94-97DD-4140-9BB5-E7D8CB02B00D@i-tool.eu"
      type="cite">
      <pre wrap="">yep, I just using it … with AirBrake …
but want to switch to something cost free…

I just testing errbit on heroku - <a class="moz-txt-link-freetext" href="https://github.com/errbit/errbit/">https://github.com/errbit/errbit/</a>

On Jul 19, 2012, at 9:52 AM, Gleb Peregud wrote:

</pre>
      <blockquote type="cite">
        <pre wrap="">On Thu, Jul 19, 2012 at 9:49 AM, Max Lapshin <a class="moz-txt-link-rfc2396E" href="mailto:max.lapshin@gmail.com"><max.lapshin@gmail.com></a> wrote:
</pre>
        <blockquote type="cite">
          <pre wrap="">I advise to take a look at hoptoad protocol: there are agents for many
languages.
</pre>
        </blockquote>
        <pre wrap="">
Including Erlang - <a class="moz-txt-link-freetext" href="https://github.com/kenpratt/erlbrake">https://github.com/kenpratt/erlbrake</a>
_______________________________________________
erlang-questions mailing list
<a class="moz-txt-link-abbreviated" href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a>
<a class="moz-txt-link-freetext" href="http://erlang.org/mailman/listinfo/erlang-questions">http://erlang.org/mailman/listinfo/erlang-questions</a>
</pre>
      </blockquote>
      <pre wrap="">
_______________________________________________
erlang-questions mailing list
<a class="moz-txt-link-abbreviated" href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a>
<a class="moz-txt-link-freetext" href="http://erlang.org/mailman/listinfo/erlang-questions">http://erlang.org/mailman/listinfo/erlang-questions</a>
</pre>
    </blockquote>
    <br>
    <br>
  </body>
</html>