Skip to content

Commit 0aaaad7

Browse files
authored
First implementation (#1)
- Async SMTP client over SwiftNIO - STARTTLS and SSL support - AUTH LOGIN - Prebuilt raw DATA payload support - Foundation free
1 parent 2cc8ae8 commit 0aaaad7

31 files changed

+1741
-1
lines changed

.github/workflows/deployment.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: Deployment
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
- '[0-9]*'
8+
9+
jobs:
10+
11+
create-docc-and-deploy:
12+
uses: BinaryBirds/github-workflows/.github/workflows/docc_deploy.yml@main
13+
permissions:
14+
contents: read
15+
pages: write
16+
id-token: write

.github/workflows/testing.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Testing
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
8+
jobs:
9+
10+
swiftlang_checks:
11+
name: Swiftlang Checks
12+
uses: swiftlang/github-workflows/.github/workflows/soundness.yml@main
13+
with:
14+
license_header_check_project_name: "project"
15+
format_check_enabled : true
16+
broken_symlink_check_enabled : true
17+
unacceptable_language_check_enabled : true
18+
shell_check_enabled : true
19+
docs_check_enabled : false
20+
api_breakage_check_enabled : false
21+
license_header_check_enabled : false
22+
yamllint_check_enabled : false
23+
python_lint_check_enabled : false
24+
25+
bb_checks:
26+
name: BB Checks
27+
uses: BinaryBirds/github-workflows/.github/workflows/extra_soundness.yml@main
28+
with:
29+
local_swift_dependencies_check_enabled : true
30+
headers_check_enabled : true
31+
docc_warnings_check_enabled : true
32+
33+
tests-with-envs:
34+
name: Test with ENVs
35+
runs-on: ubuntu-latest
36+
strategy:
37+
matrix:
38+
swift:
39+
- "6.1"
40+
- "6.2"
41+
42+
steps:
43+
- name: Checkout
44+
uses: actions/checkout@v4
45+
46+
- name: Test
47+
env:
48+
SMTP_HOST: ${{ secrets.SMTP_HOST }}
49+
SMTP_USER: ${{ secrets.SMTP_USER }}
50+
SMTP_PASS: ${{ secrets.SMTP_PASS }}
51+
SMTP_FROM: ${{ secrets.SMTP_FROM }}
52+
SMTP_TO: ${{ secrets.SMTP_TO }}
53+
run: swift test --parallel --enable-code-coverage

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
.DS_Store
2+
.build
3+
Packages
4+
*.xcodeproj
5+
xcuserdata
6+
DerivedData
7+
.swiftpm
8+
*.xctestplan

.swift-format

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
{
2+
"fileScopedDeclarationPrivacy" : {
3+
"accessLevel" : "private"
4+
},
5+
"indentation" : {
6+
"spaces" : 4
7+
},
8+
"indentConditionalCompilationBlocks" : false,
9+
"indentSwitchCaseLabels" : false,
10+
"lineBreakAroundMultilineExpressionChainComponents" : true,
11+
"lineBreakBeforeControlFlowKeywords" : true,
12+
"lineBreakBeforeEachArgument" : true,
13+
"lineBreakBeforeEachGenericRequirement" : true,
14+
"lineLength" : 80,
15+
"maximumBlankLines" : 1,
16+
"prioritizeKeepingFunctionOutputTogether" : false,
17+
"respectsExistingLineBreaks" : true,
18+
"rules" : {
19+
"AllPublicDeclarationsHaveDocumentation" : true,
20+
"AlwaysUseLowerCamelCase" : false,
21+
"AmbiguousTrailingClosureOverload" : true,
22+
"BeginDocumentationCommentWithOneLineSummary" : false,
23+
"DoNotUseSemicolons" : true,
24+
"DontRepeatTypeInStaticProperties" : false,
25+
"FileScopedDeclarationPrivacy" : true,
26+
"FullyIndirectEnum" : true,
27+
"GroupNumericLiterals" : true,
28+
"IdentifiersMustBeASCII" : true,
29+
"NeverForceUnwrap" : false,
30+
"NeverUseForceTry" : false,
31+
"NeverUseImplicitlyUnwrappedOptionals" : false,
32+
"NoAccessLevelOnExtensionDeclaration" : false,
33+
"NoAssignmentInExpressions" : true,
34+
"NoBlockComments" : true,
35+
"NoCasesWithOnlyFallthrough" : true,
36+
"NoEmptyTrailingClosureParentheses" : true,
37+
"NoLabelsInCasePatterns" : false,
38+
"NoLeadingUnderscores" : false,
39+
"NoParensAroundConditions" : true,
40+
"NoVoidReturnOnFunctionSignature" : true,
41+
"OneCasePerLine" : true,
42+
"OneVariableDeclarationPerLine" : true,
43+
"OnlyOneTrailingClosureArgument" : true,
44+
"OrderedImports" : false,
45+
"ReturnVoidInsteadOfEmptyTuple" : true,
46+
"UseEarlyExits" : false,
47+
"UseLetInEveryBoundCaseVariable" : false,
48+
"UseShorthandTypeNames" : true,
49+
"UseSingleLinePropertyGetter" : false,
50+
"UseSynthesizedInitializer" : true,
51+
"UseTripleSlashForDocumentationComments" : true,
52+
"UseWhereClausesInForLoops" : false,
53+
"ValidateDocumentationComments" : true
54+
},
55+
"spacesAroundRangeFormationOperators" : false,
56+
"tabWidth" : 4,
57+
"version" : 1
58+
}

.swiftformatignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Package.swift

LICENSE

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
MIT License
2+
3+
Copyright (c) 2018-2022 Tibor Bödecs
4+
Copyright (c) 2022-2026 Binary Birds Kft.
5+
6+
Permission is hereby granted, free of charge, to any person
7+
obtaining a copy of this software and associated documentation
8+
files (the "Software"), to deal in the Software without
9+
restriction, including without limitation the rights to use,
10+
copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
copies of the Software, and to permit persons to whom the
12+
Software is furnished to do so, subject to the following
13+
conditions:
14+
15+
The above copyright notice and this permission notice shall be
16+
included in all copies or substantial portions of the Software.
17+
18+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
20+
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
22+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
23+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
25+
OTHER DEALINGS IN THE SOFTWARE.

Makefile

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
SHELL=/bin/bash
2+
3+
baseUrl = https://raw.githubusercontent.com/BinaryBirds/github-workflows/refs/heads/main/scripts
4+
5+
check: symlinks language deps lint docc-warnings headers
6+
7+
symlinks:
8+
curl -s $(baseUrl)/check-broken-symlinks.sh | bash
9+
10+
language:
11+
curl -s $(baseUrl)/check-unacceptable-language.sh | bash
12+
13+
deps:
14+
curl -s $(baseUrl)/check-local-swift-dependencies.sh | bash
15+
16+
lint:
17+
curl -s $(baseUrl)/run-swift-format.sh | bash
18+
19+
format:
20+
curl -s $(baseUrl)/run-swift-format.sh | bash -s -- --fix
21+
22+
docc-local:
23+
curl -s $(baseUrl)/generate-docc.sh | bash -s -- --local
24+
25+
run-docc:
26+
curl -s $(baseUrl)/run-docc-docker.sh | bash
27+
28+
docc-warnings:
29+
curl -s $(baseUrl)/check-docc-warnings.sh | bash
30+
31+
headers:
32+
curl -s $(baseUrl)/check-swift-headers.sh | bash
33+
34+
fix-headers:
35+
curl -s $(baseUrl)/check-swift-headers.sh | bash -s -- --fix
36+
37+
test:
38+
swift test --parallel
39+
40+
docker-test:
41+
docker build -t tests . -f ./docker/tests/Dockerfile && docker run --rm tests
42+

Package.resolved

Lines changed: 60 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Package.swift

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
// swift-tools-version:6.1
2+
import PackageDescription
3+
4+
// NOTE: https://github.com/swift-server/swift-http-server/blob/main/Package.swift
5+
var defaultSwiftSettings: [SwiftSetting] = [
6+
7+
// https://github.com/swiftlang/swift-evolution/blob/main/proposals/0441-formalize-language-mode-terminology.md
8+
.swiftLanguageMode(.v6),
9+
// https://github.com/swiftlang/swift-evolution/blob/main/proposals/0444-member-import-visibility.md
10+
.enableUpcomingFeature("MemberImportVisibility"),
11+
// https://forums.swift.org/t/experimental-support-for-lifetime-dependencies-in-swift-6-2-and-beyond/78638
12+
.enableExperimentalFeature("Lifetimes"),
13+
// https://github.com/swiftlang/swift/pull/65218
14+
.enableExperimentalFeature("AvailabilityMacro=swiftNIOSMTP:macOS 15, iOS 18, watchOS 11, tvOS 18, visionOS 2"),
15+
]
16+
17+
#if compiler(>=6.2)
18+
defaultSwiftSettings.append(
19+
// https://github.com/swiftlang/swift-evolution/blob/main/proposals/0461-async-function-isolation.md
20+
.enableUpcomingFeature("NonisolatedNonsendingByDefault")
21+
)
22+
#endif
23+
24+
let package = Package(
25+
name: "swift-nio-smtp",
26+
platforms: [
27+
.macOS(.v15),
28+
.iOS(.v18),
29+
.tvOS(.v18),
30+
.watchOS(.v11),
31+
.visionOS(.v2),
32+
],
33+
products: [
34+
.library(name: "NIOSMTP", targets: ["NIOSMTP"]),
35+
],
36+
dependencies: [
37+
// [docc-plugin-placeholder]
38+
.package(url: "https://github.com/apple/swift-log", from: "1.6.0"),
39+
.package(url: "https://github.com/apple/swift-nio", from: "2.0.0"),
40+
.package(url: "https://github.com/apple/swift-nio-ssl", from: "2.0.0"),
41+
],
42+
targets: [
43+
.target(
44+
name: "NIOSMTP",
45+
dependencies: [
46+
.product(name: "NIO", package: "swift-nio"),
47+
.product(name: "NIOCore", package: "swift-nio"),
48+
.product(name: "NIOSSL", package: "swift-nio-ssl"),
49+
.product(name: "Logging", package: "swift-log"),
50+
]
51+
),
52+
.testTarget(
53+
name: "NIOSMTPTests",
54+
dependencies: [
55+
.target(name: "NIOSMTP"),
56+
.product(name: "NIO", package: "swift-nio"),
57+
.product(name: "Logging", package: "swift-log"),
58+
]
59+
)
60+
]
61+
)

0 commit comments

Comments
 (0)