Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,15 @@ A template is provided:
- Indicate if changes are major, minor, or patch changes.
```

## 0.5.1.0

- [#43](https://github.com/haskell-github-trust/smtp-mail/pull/43) @spencerjanssen
- The `Bcc` header is stripped from the message before sending it to the
SMTP server. Previously, every recipient could see the Bcc addresses
unless the server happened to strip the header itself.

## 0.5.0.2

- [#119](https://github.com/haskell-github-trust/smtp-mail/pull/119) @ysangkok
- Use `getHostName` from `network` instead of `network-bsd`, fixing the build with `network >= 3.2.10`
- Drop the `network-bsd` dependency and require `network >= 3.2.10`
Expand Down
7 changes: 5 additions & 2 deletions Network/Mail/SMTP.hs
Original file line number Diff line number Diff line change
Expand Up @@ -325,12 +325,15 @@ sendRenderedMail sender receivers dat conn = do
-- 'SMTPConnection'
renderAndSend ::SMTPConnection -> Mail -> IO ()
renderAndSend conn mail@Mail{..} = do
rendered <- lazyToStrict `fmap` renderMail' mail
rendered <- lazyToStrict `fmap` renderMail' (removeBcc mail)
sendRenderedMail from to rendered conn
where enc = encodeUtf8 . addressEmail
from = enc mailFrom
to = map enc $ mailTo ++ mailCc ++ mailBcc

removeBcc :: Mail -> Mail
removeBcc mail = mail {mailBcc = []}

sendMailOnConnection :: Mail -> SMTPConnection -> IO ()
sendMailOnConnection mail con = do
renderAndSend con mail
Expand Down Expand Up @@ -435,7 +438,7 @@ sendMailWithSenderIntern sender mail con = do

renderAndSendFrom :: ByteString -> SMTPConnection -> Mail -> IO ()
renderAndSendFrom sender conn mail@Mail{..} = do
rendered <- BL.toStrict `fmap` renderMail' mail
rendered <- BL.toStrict `fmap` renderMail' (removeBcc mail)
sendRenderedMail sender to rendered conn
where enc = encodeUtf8 . addressEmail
to = map enc $ mailTo ++ mailCc ++ mailBcc
Expand Down
14 changes: 14 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@
enableSubmissions = true;
settings.main = {
tlsTrustedAuthorities = "${certs.ca.cert}";
home_mailbox = "Maildir/";
mydestination = "localhost, acme.test";
local_recipient_maps = "";
myhostname = "acme.test";
# Postfix strips Bcc headers by default, which would mask
# smtp-mail leaking them. Keep the rest of the default list.
message_drop_headers = "content-length, return-path";
smtpd_tls_chain_files = [
certs."acme.test".key
certs."acme.test".cert
Expand Down Expand Up @@ -69,6 +76,13 @@
testScript = ''
machine.wait_for_unit("postfix.service")
machine.succeed("integration-test")
machine.succeed("grep -l '^Subject: Test Plain$' /home/alice/Maildir/new/*")
machine.succeed("grep -l '^Subject: Test TLS$' /home/alice/Maildir/new/*")
machine.succeed("grep -l '^Subject: Test STARTTLS$' /home/alice/Maildir/new/*")
machine.succeed("grep -l '^Subject: Test Bcc$' /home/alice/Maildir/new/*")
machine.succeed("grep -l '^Subject: Test Bcc$' /home/bob/Maildir/new/*")
machine.fail("grep -il '^bcc:' /home/alice/Maildir/new/* /home/bob/Maildir/new/*")
machine.fail("grep -l 'bob@acme.test' /home/alice/Maildir/new/*")
'';
};
};
Expand Down
17 changes: 11 additions & 6 deletions nix-integration-test/integration-test/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,27 @@
module Main where

import Network.Mail.SMTP hiding (simpleMail)
import Network.Mail.Mime (simpleMail)
import Network.Mail.Mime (simpleMail, Mail(..))
import System.Environment as Env
import Test.Hspec
import Test.Hspec.Expectations

from = Address Nothing "integration-test-smtp-mail@acme.test"
to = Address (Just "alice") "alice@acme.test"
subject = "Test Mail"
subject = "Test"
body = "Test Mail Body Part"
html = "<h1>This Test succeeded!</h1>"

createMail = simpleMail to from subject body html []
createMail label = simpleMail to from (subject <> " " <> label) body html []

host = "acme.test"

doPlainSmtp = createMail >>= sendMail host
doTlsSmtp = createMail >>= sendMailTLS host
doSTARTTLS = createMail >>= sendMailSTARTTLS host
doPlainSmtp = createMail "Plain" >>= sendMail host
doTlsSmtp = createMail "TLS" >>= sendMailTLS host
doSTARTTLS = createMail "STARTTLS" >>= sendMailSTARTTLS host
doBcc = do
mail <- createMail "Bcc"
sendMail host mail { mailBcc = [Address (Just "bob") "bob@acme.test"] }

main :: IO ()
main = hspec $ do
Expand All @@ -30,3 +33,5 @@ main = hspec $ do
doTlsSmtp `shouldReturn` ()
it "using STARTTLS" $ do
doSTARTTLS `shouldReturn` ()
it "using Bcc" $ do
doBcc `shouldReturn` ()
2 changes: 1 addition & 1 deletion smtp-mail.cabal
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: smtp-mail
version: 0.5.0.2
version: 0.5.1.0
synopsis: Simple email sending via SMTP
description: This packages provides a simple interface for mail over SMTP. Please see the README for more information.
homepage: http://github.com/haskell-github-trust/smtp-mail
Expand Down