[Haskell-cafe] Re: Should Yesod.Mail be a separate package?
Michael Snoyman
michael at snoyman.com
Mon Oct 18 07:29:57 EDT 2010
On Sun, Oct 17, 2010 at 7:07 PM, Jeremy Shaw <jeremy at n-heptane.com> wrote:
> On Sun, Oct 17, 2010 at 10:14 AM, Michael Snoyman <michael at snoyman.com> wrote:
>
>> I'm sure people would love to see built-in support for serving over
>> SMTP, but I think that's more appropriate for a different package.
>> Proper SMTP support will also include SSL/TLS support, which will
>> require even more dependencies.
>
> SMTPClient,
>
> http://hackage.haskell.org/package/SMTPClient-1.0.3
>
> can be used to send mail via SMTP to a smart host. It is still based
> on 'String', but it is a start. To send a simple message you can do:
>
> import Network.SMTP.Simple
> import System.IO
>
> main :: IO ()
> main = do
> sendSimpleMessages (hPutStrLn stderr) "10.2.23.11" "example.com" [message]
> where message = SimpleMessage
> [NameAddr (Just "John Doe") "johnd at example.com"]
> [NameAddr (Just "Team") "team at exmaple.com"]
> "My test email using Network.SMTP.Simple"
> "Hi, this is a test email which uses SMTPClient."
>
> I wonder what it would take to make it so that the message body could
> be multipart mime...
Currently, the idea in mime-mail is to produce fully-formed messages,
complete with headers, encoded as UTF-8 lazy bytestrings. To address
the headers issue, we would need to do one of:
* Allow SMTPClient to accept messages with the headers already attached.
* Modify mime-mail to produce a list of headers separate from the
message content. I'm not opposed to this.
Regarding the String/ByteString issue, there are three choices I believe:
* Switch mime-mail to use Strings. I *am* opposed to this ;).
* Switch SMTPClient to use ByteStrings. I think this is the right answer.
* Leave the libraries as-is, and just use a Lazy.Char8.unpack to bridge the two.
Am I leaving anything out? I'd be happy to try and get mime-mail to
work with SMTPClient.
Michael
More information about the Haskell-Cafe
mailing list