Skip to content

Commit f269e8a

Browse files
authored
Merge pull request #37 from dpwright/mangoiv/ci
add initial ci and cut release
2 parents d7a6762 + fe1edd9 commit f269e8a

File tree

5 files changed

+105
-15
lines changed

5 files changed

+105
-15
lines changed

.github/workflows/haskell.yml

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: haskell ci
2+
on:
3+
workflow_dispatch:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
branches:
9+
- master
10+
11+
jobs:
12+
generate-matrix:
13+
name: "Generate matrix from cabal"
14+
outputs:
15+
matrix: ${{ steps.set-matrix.outputs.matrix }}
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Extract the tested GHC versions
19+
id: set-matrix
20+
uses: kleidukos/[email protected]
21+
with:
22+
cabal-file: HaskellNet-SSL.cabal
23+
ubuntu-version: "latest"
24+
macos-version: "latest"
25+
windows-version: "latest"
26+
version: 0.1.7.0
27+
tests:
28+
name: ${{ matrix.ghc }} on ${{ matrix.os }}
29+
needs: generate-matrix
30+
runs-on: ${{ matrix.os }}
31+
strategy:
32+
matrix: ${{ fromJSON(needs.generate-matrix.outputs.matrix) }}
33+
steps:
34+
- name: Checkout repo
35+
uses: actions/checkout@v4
36+
- name: Set up Haskell
37+
id: setup-haskell
38+
uses: haskell-actions/setup@v2
39+
with:
40+
ghc-version: ${{ matrix.ghc }}
41+
cabal-version: 'latest'
42+
- name: Update
43+
run: cabal update
44+
- name: Freeze
45+
run: cabal freeze
46+
- name: Cache
47+
uses: actions/[email protected]
48+
with:
49+
path: ${{ steps.setup-haskell.outputs.cabal-store }}
50+
key: ${{ runner.os }}-${{ matrix.ghc }}-${{ hashFiles('cabal.project.freeze') }}
51+
restore-keys: ${{ runner.os }}-${{ matrix.ghc }}-
52+
- name: Build
53+
run: cabal build

CHANGELOG.md

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Revision history for HaskellNet-SSL
2+
3+
## 0.4.0.0 -- 2025-01-07
4+
5+
- drop support for connection in favour of crypton-connection
6+
- compatibility with GHCs up to ghc 9.8 (bump base and bytestring)
7+
- fix example
8+
- add tested-with stanza

HaskellNet-SSL.cabal

+17-5
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
11
name: HaskellNet-SSL
22
synopsis: Helpers to connect to SSL/TLS mail servers with HaskellNet
3-
version: 0.3.4.4
3+
version: 0.4.0.0
44
description: This package ties together the HaskellNet and connection
55
packages to make it easy to open IMAP and SMTP connections
66
over SSL.
77
homepage: https://github.com/dpwright/HaskellNet-SSL
8+
tested-with: GHC ==9.4.8 || ==9.6.5 || ==9.8.2
89
license: BSD3
910
license-file: LICENSE
1011
author: Daniel P. Wright
11-
maintainer: Leza M. Lutonda <[email protected]>, [email protected]
12+
1213
copyright: (c) 2013 Daniel P. Wright
1314
category: Network
1415
build-type: Simple
15-
cabal-version: >=1.10
16-
data-files: README.md
16+
cabal-version: 1.18
17+
extra-doc-files: README.md, CHANGELOG.md
1718

1819
flag network-bsd
1920
description: Get Network.BSD from the network-bsd package
@@ -34,11 +35,22 @@ library
3435
other-modules: Network.HaskellNet.SSL.Internal
3536
build-depends: base >= 4 && < 5,
3637
HaskellNet >= 0.3 && < 0.7,
37-
crypton-connection >= 0.3.1,
38+
crypton-connection >= 0.3.1 && < 0.5,
3839
bytestring >= 0.9 && < 0.13,
3940
data-default >= 0.2 && < 0.8
4041
if flag(network-bsd)
4142
build-depends: network >= 3.0 && < 3.2,
4243
network-bsd >= 2.7 && < 2.9
4344
else
4445
build-depends: network >= 2.4 && < 3.0
46+
47+
executable HaskellNet-SSL-example
48+
hs-source-dirs: examples
49+
main-is: gmail.hs
50+
other-modules:
51+
build-depends: base,
52+
HaskellNet-SSL,
53+
HaskellNet,
54+
bytestring
55+
56+
default-language: Haskell2010

README.md

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
1-
HaskellNet-SSL
2-
--------------
1+
# HaskellNet-SSL
32

4-
[![Build Status](https://travis-ci.org/dpwright/HaskellNet-SSL.svg?branch=master)](https://travis-ci.org/dpwright/HaskellNet-SSL)
3+
[![haskell ci](https://github.com/dpwright/HaskellNet-SSL/actions/workflows/haskell.yml/badge.svg)](https://github.com/dpwright/HaskellNet-SSL/actions/workflows/haskell.yml)
54

65
This package ties together the excellent [HaskellNet][HaskellNet] and
7-
[connection][connection] packages to make it easy to open IMAP and SMTP
6+
[crypton-connection][crypton-connection] packages to make it easy to open IMAP and SMTP
87
connections over SSL. This is a simple "glue" library; all credit for a)
98
connecting to IMAP/SMTP servers and b) making an SSL connection goes to the
109
aforementioned libraries.
1110

1211
[HaskellNet]: https://github.com/jtdaugherty/HaskellNet
13-
[connection]: https://github.com/vincenthz/hs-connection
12+
[crypton-connection]: https://github.com/kazu-yamamoto/crypton-connection

examples/gmail.hs

+23-5
Original file line numberDiff line numberDiff line change
@@ -3,34 +3,52 @@
33
import Network.HaskellNet.IMAP.SSL
44
import Network.HaskellNet.SMTP.SSL as SMTP
55

6-
import Network.HaskellNet.Auth (AuthType(LOGIN))
6+
import Network.HaskellNet.Auth (AuthType(LOGIN), Password)
7+
import Network.Mail.Mime
78

89
import qualified Data.ByteString.Char8 as B
10+
import Data.String
911

12+
username :: IsString s => s
1013
username = "[email protected]"
14+
15+
password :: Password
1116
password = "password"
17+
18+
recipient :: Address
1219
recipient = "[email protected]"
1320

21+
imapTest :: IO ()
1422
imapTest = do
1523
c <- connectIMAPSSLWithSettings "imap.gmail.com" cfg
1624
login c username password
1725
mboxes <- list c
1826
mapM_ print mboxes
1927
select c "INBOX"
20-
msgs <- search c [ALLs]
21-
let firstMsg = head msgs
28+
msgs@(firstMsg : _) <- search c [ALLs]
2229
msgContent <- fetch c firstMsg
2330
B.putStrLn msgContent
2431
logout c
2532
where cfg = defaultSettingsIMAPSSL { sslMaxLineLength = 100000 }
2633

34+
smtpTest :: IO ()
2735
smtpTest = doSMTPSTARTTLS "smtp.gmail.com" $ \c -> do
2836
authSucceed <- SMTP.authenticate LOGIN username password c
2937
if authSucceed
30-
then sendPlainTextMail recipient username subject body c
38+
then do
39+
mail <- simpleMail
40+
recipient
41+
username
42+
subject
43+
body
44+
mempty
45+
mempty
46+
sendMail mail c -- recipient username subject body
3147
else print "Authentication error."
3248
where subject = "Test message"
3349
body = "This is a test message"
3450

3551
main :: IO ()
36-
main = smtpTest >> imapTest >> return ()
52+
main = do
53+
smtpTest
54+
imapTest

0 commit comments

Comments
 (0)