Skip to content

Remove BCC before sending mail #43

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ A template is provided:
- Indicate if changes are major, minor, or patch changes.
```

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

## 0.5.0.0

- Adds support for OAuth authentication with a new function `sendMailWithLoginOAuthSTARTTLS`.
Expand Down
7 changes: 5 additions & 2 deletions Network/Mail/SMTP.hs
Original file line number Diff line number Diff line change
Expand Up @@ -326,12 +326,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 @@ -436,7 +439,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
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.0
version: 0.5.0.1
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