Skip to content

Commit 4bd2e84

Browse files
Remove BCC before sending mail
1 parent bfa78c4 commit 4bd2e84

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ A template is provided:
2020
- Indicate if changes are major, minor, or patch changes.
2121
```
2222

23+
## 0.5.0.1
24+
- [#39](https://github.com/jhickner/smtp-mail/pull/39) @spencerjanssen
25+
- The `Bcc` field is stripped from the message before sending to the SMTP
26+
server. This is to prevent leaking the BCC contents to recipients.
27+
2328
## 0.5.0.0
2429

2530
- Adds support for OAuth authentication with a new function `sendMailWithLoginOAuthSTARTTLS`.

Network/Mail/SMTP.hs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -326,12 +326,15 @@ sendRenderedMail sender receivers dat conn = do
326326
-- 'SMTPConnection'
327327
renderAndSend ::SMTPConnection -> Mail -> IO ()
328328
renderAndSend conn mail@Mail{..} = do
329-
rendered <- lazyToStrict `fmap` renderMail' mail
329+
rendered <- lazyToStrict `fmap` renderMail' (removeBcc mail)
330330
sendRenderedMail from to rendered conn
331331
where enc = encodeUtf8 . addressEmail
332332
from = enc mailFrom
333333
to = map enc $ mailTo ++ mailCc ++ mailBcc
334334

335+
removeBcc :: Mail -> Mail
336+
removeBcc mail = mail {mailBcc = []}
337+
335338
sendMailOnConnection :: Mail -> SMTPConnection -> IO ()
336339
sendMailOnConnection mail con = do
337340
renderAndSend con mail
@@ -436,7 +439,7 @@ sendMailWithSenderIntern sender mail con = do
436439

437440
renderAndSendFrom :: ByteString -> SMTPConnection -> Mail -> IO ()
438441
renderAndSendFrom sender conn mail@Mail{..} = do
439-
rendered <- BL.toStrict `fmap` renderMail' mail
442+
rendered <- BL.toStrict `fmap` renderMail' (removeBcc mail)
440443
sendRenderedMail sender to rendered conn
441444
where enc = encodeUtf8 . addressEmail
442445
to = map enc $ mailTo ++ mailCc ++ mailBcc

smtp-mail.cabal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: smtp-mail
2-
version: 0.5.0.0
2+
version: 0.5.0.1
33
synopsis: Simple email sending via SMTP
44
description: This packages provides a simple interface for mail over SMTP. Please see the README for more information.
55
homepage: http://github.com/haskell-github-trust/smtp-mail

0 commit comments

Comments
 (0)