11

I'm unable to find any good documentation or examples of how to send an mail to an email address using Yesod.

More practically, I'll extract the information the user typed inside a simple form (name, age, body of message) and send this information as a mail to an email address.

I'm kind of lost in this task.

ROMANIA_engineer
  • 54,432
  • 29
  • 203
  • 199
kolam
  • 731
  • 4
  • 17

2 Answers2

13

There are three packages I'd recommend you look at:

  • mime-mail, which is a package for composing emails and rendering to bytestrings. It can also send via the system sendmail executable.
  • mime-mail-ses, which can send mail from mime-mail via Amazon SES.
  • smtp-mail, which can send mail from mime-mail via an SMTP connection.

There is some discussion about sending email in the auth chapter of the Yesod book.

Michael Snoyman
  • 31,100
  • 3
  • 48
  • 77
  • Thanks for the answer. When I look into these packages, they have methods to send an email (methods that return IO () ). How do you use those methods inside Yesod? When I extract the content of the simple form, I'm inside a Handler which returns a Widget. Where in the code can I send this email? Thanks. – kolam Mar 20 '14 at 23:44
  • 1
    You can use liftIO to run an IO action in either the Handler or Widget monads. – Michael Snoyman Mar 21 '14 at 03:51
4

Yesod doesn't have mailing functions. You have to use other packages outside Yesod.

Maybe you'd want to check this short answer: https://stackoverflow.com/a/11763447/1744195

Community
  • 1
  • 1