Skip to content

Commit

Permalink
update bluecryptor to 1.0.2. add swift 4.1 support (#73)
Browse files Browse the repository at this point in the history
* update bluecryptor to 1.0.2. add swift 4.1 support

* loosen spm versioning

* linux swift build failure

* linux

* linux

* linux

* linux

* update docs and regen jazzy
  • Loading branch information
quanvo87 authored Apr 30, 2018
1 parent 3958929 commit b6ca1ea
Show file tree
Hide file tree
Showing 38 changed files with 1,117 additions and 341 deletions.
41 changes: 30 additions & 11 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,27 +1,45 @@
// swift-tools-version:4.0
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

#if swift(>=4.1)
let package = Package(
name: "SwiftSMTP",
products: [
// Products define the executables and libraries produced by a package, and make them visible to other packages.
.library(
name: "SwiftSMTP",
targets: ["SwiftSMTP"]),
],
dependencies: [
// Dependencies declare other packages that this package depends on.
// .package(url: /* package url */, from: "1.0.0"),
.package(url: "https://github.com/IBM-Swift/BlueSocket.git", .upToNextMinor(from: "0.12.0")),
.package(url: "https://github.com/IBM-Swift/BlueSSLService.git", .upToNextMinor(from: "0.12.0")),
.package(url: "https://github.com/IBM-Swift/BlueCryptor.git", .upToNextMinor(from: "0.8.0")),
.package(url: "https://github.com/IBM-Swift/LoggerAPI.git", .upToNextMinor(from: "1.7.0")),
],
.package(url: "https://github.com/IBM-Swift/BlueSocket.git", from: "0.12.0"),
.package(url: "https://github.com/IBM-Swift/BlueSSLService.git", from: "0.12.0"),
.package(url: "https://github.com/IBM-Swift/BlueCryptor.git", from: "1.0.0"),
.package(url: "https://github.com/IBM-Swift/LoggerAPI.git", from: "1.7.0"),
],
targets: [
.target(
name: "SwiftSMTP",
dependencies: ["Socket", "SSLService", "Cryptor", "LoggerAPI"]),
.testTarget(
name: "SwiftSMTPTests",
dependencies: ["SwiftSMTP"]),
]
)
#else
let package = Package(
name: "SwiftSMTP",
products: [
.library(
name: "SwiftSMTP",
targets: ["SwiftSMTP"]),
],
dependencies: [
.package(url: "https://github.com/IBM-Swift/BlueSocket.git", from: "0.12.0"),
.package(url: "https://github.com/IBM-Swift/BlueSSLService.git", from: "0.12.0"),
.package(url: "https://github.com/IBM-Swift/BlueCryptor.git", from: "0.8.0"),
.package(url: "https://github.com/IBM-Swift/LoggerAPI.git", from: "1.7.0"),
],
targets: [
// Targets are the basic building blocks of a package. A target defines a module or a test suite.
// Targets can depend on other targets in this package, and on products in packages which this package depends on.
.target(
name: "SwiftSMTP",
dependencies: ["Socket", "SSLService", "Cryptor", "LoggerAPI"]),
Expand All @@ -30,3 +48,4 @@ let package = Package(
dependencies: ["SwiftSMTP"]),
]
)
#endif
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Swift SMTP client.

## Swift Version

macOS & Linux: `Swift 4.0.3`
macOS & Linux: `Swift 4.0.3` or `Swift 4.1`

## Migration Guide

Expand Down
1 change: 1 addition & 0 deletions Sources/SwiftSMTP/Attachment.swift
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ extension Attachment {
}

extension Attachment: Equatable {
/// Returns `true` if the `Attachment`s are equal.
public static func ==(lhs: Attachment, rhs: Attachment) -> Bool {
return lhs.additionalHeaders == rhs.additionalHeaders &&
lhs.hasRelated == rhs.hasRelated &&
Expand Down
2 changes: 2 additions & 0 deletions Sources/SwiftSMTP/AuthMethod.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
* limitations under the License.
**/

import Foundation

/// Supported authentication methods for logging into the SMTP server.
public enum AuthMethod: String {
/// CRAM-MD5 authentication.
Expand Down
6 changes: 3 additions & 3 deletions Sources/SwiftSMTP/Mail.swift
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public struct Mail {
return (nil, attachments)
}

var headersDictionary: [String: String] {
private var headersDictionary: [String: String] {
var dictionary = [String: String]()
dictionary["MESSAGE-ID"] = id
dictionary["DATE"] = Date().smtpFormatted
Expand Down Expand Up @@ -148,10 +148,10 @@ public struct Mail {
extension Mail {
/// Represents a sender or receiver of an email.
public struct User {
// The user's name that is displayed in an email. Optional.
/// The user's name that is displayed in an email. Optional.
public let name: String?

// The user's email address.
/// The user's email address.
public let email: String

/// Initializes a `User`.
Expand Down
4 changes: 4 additions & 0 deletions Sources/SwiftSMTP/MailSender.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@ import Foundation
import Dispatch
#endif

/// (`Mail`, `Error`) callback after each `Mail` is sent. `Mail` is the mail sent and `Error` is the error if it failed.
public typealias Progress = ((Mail, Error?) -> Void)?

/// ([`Mail`], [(`Mail`, `Error`)]) callback after all `Mail`s have been attempted. [`Mail`] is an array of successfully
/// sent `Mail`s. [(`Mail`, `Error`)] is an array of failed `Mail`s and their corresponding `Error`s.
public typealias Completion = (([Mail], [(Mail, Error)]) -> Void)?

class MailSender {
Expand Down
2 changes: 2 additions & 0 deletions Sources/SwiftSMTP/SMTP.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
* limitations under the License.
**/

import Foundation

/// Used to connect to an SMTP server and send emails.
public struct SMTP {
private let hostname: String
Expand Down
2 changes: 1 addition & 1 deletion Sources/SwiftSMTP/SMTPError.swift
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public enum SMTPError: Error, CustomStringConvertible {
case .invalidEmail(let email): return "Invalid email provided for User: \(email)."
}
}

init(_ error: SMTPError) {
self = error
Log.error(description)
Expand Down
13 changes: 13 additions & 0 deletions Sources/SwiftSMTP/SMTPSocket.swift
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,18 @@ private extension SMTPSocket {
guard !responsesArray.isEmpty else {
throw SMTPError.badResponse(command: command.text, response: responses)
}
#if swift(>=4.1)
return try responsesArray.compactMap { response in
guard response != "" else {
return nil
}
return Response(
code: try getResponseCode(response, command: command),
message: getResponseMessage(response),
response: response
)
}
#else
return try responsesArray.flatMap { response in
guard response != "" else {
return nil
Expand All @@ -93,6 +105,7 @@ private extension SMTPSocket {
response: response
)
}
#endif
}

func getResponseCode(_ response: String, command: Command) throws -> ResponseCode {
Expand Down
19 changes: 15 additions & 4 deletions docs/Enums.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<a class="header-link" href="index.html">
SwiftSMTP Docs
</a>
(95% documented)
(100% documented)
</p>

<p class="header-col--secondary">
Expand Down Expand Up @@ -69,14 +69,25 @@
<li class="nav-group-task">
<a class="nav-group-task-link" href="Structs/Mail.html">Mail</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="Structs/Mail/User.html">– User</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="Structs/SMTP.html">SMTP</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="Structs/TLSConfiguration.html">TLSConfiguration</a>
</li>
</ul>
</li>
<li class="nav-group-name">
<a class="nav-group-name-link" href="Typealiases.html">Type Aliases</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a class="nav-group-task-link" href="Typealiases.html#/s:9SwiftSMTP10Completiona">Completion</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="Structs/User.html">User</a>
<a class="nav-group-task-link" href="Typealiases.html#/s:9SwiftSMTP8Progressa">Progress</a>
</li>
</ul>
</li>
Expand Down Expand Up @@ -109,7 +120,7 @@ <h1>Enumerations</h1>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
<p>Undocumented</p>
<p>Supported authentication methods for logging into the SMTP server.</p>

<a href="Enums/AuthMethod.html" class="slightly-smaller">See more</a>
</div>
Expand Down Expand Up @@ -164,7 +175,7 @@ <h4>Declaration</h4>
</article>
</div>
<section class="footer">
<p>&copy; 2018 <a class="link" href="" target="_blank" rel="external">IBM</a>. All rights reserved. (Last updated: 2018-04-23)</p>
<p>&copy; 2018 <a class="link" href="" target="_blank" rel="external">IBM</a>. All rights reserved. (Last updated: 2018-04-30)</p>
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.9.0</a>, a <a class="link" href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
</section>
</body>
Expand Down
19 changes: 15 additions & 4 deletions docs/Enums/AuthMethod.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<a class="header-link" href="../index.html">
SwiftSMTP Docs
</a>
(95% documented)
(100% documented)
</p>

<p class="header-col--secondary">
Expand Down Expand Up @@ -70,14 +70,25 @@
<li class="nav-group-task">
<a class="nav-group-task-link" href="../Structs/Mail.html">Mail</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="../Structs/Mail/User.html">– User</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="../Structs/SMTP.html">SMTP</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="../Structs/TLSConfiguration.html">TLSConfiguration</a>
</li>
</ul>
</li>
<li class="nav-group-name">
<a class="nav-group-name-link" href="../Typealiases.html">Type Aliases</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a class="nav-group-task-link" href="../Typealiases.html#/s:9SwiftSMTP10Completiona">Completion</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="../Structs/User.html">User</a>
<a class="nav-group-task-link" href="../Typealiases.html#/s:9SwiftSMTP8Progressa">Progress</a>
</li>
</ul>
</li>
Expand All @@ -94,7 +105,7 @@ <h1>AuthMethod</h1>

</div>
</div>
<p>Undocumented</p>
<p>Supported authentication methods for logging into the SMTP server.</p>

</div>
</section>
Expand Down Expand Up @@ -231,7 +242,7 @@ <h4>Declaration</h4>
</article>
</div>
<section class="footer">
<p>&copy; 2018 <a class="link" href="" target="_blank" rel="external">IBM</a>. All rights reserved. (Last updated: 2018-04-23)</p>
<p>&copy; 2018 <a class="link" href="" target="_blank" rel="external">IBM</a>. All rights reserved. (Last updated: 2018-04-30)</p>
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.9.0</a>, a <a class="link" href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
</section>
</body>
Expand Down
23 changes: 17 additions & 6 deletions docs/Enums/SMTPError.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<a class="header-link" href="../index.html">
SwiftSMTP Docs
</a>
(95% documented)
(100% documented)
</p>

<p class="header-col--secondary">
Expand Down Expand Up @@ -70,14 +70,25 @@
<li class="nav-group-task">
<a class="nav-group-task-link" href="../Structs/Mail.html">Mail</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="../Structs/Mail/User.html">– User</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="../Structs/SMTP.html">SMTP</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="../Structs/TLSConfiguration.html">TLSConfiguration</a>
</li>
</ul>
</li>
<li class="nav-group-name">
<a class="nav-group-name-link" href="../Typealiases.html">Type Aliases</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a class="nav-group-task-link" href="../Typealiases.html#/s:9SwiftSMTP10Completiona">Completion</a>
</li>
<li class="nav-group-task">
<a class="nav-group-task-link" href="../Structs/User.html">User</a>
<a class="nav-group-task-link" href="../Typealiases.html#/s:9SwiftSMTP8Progressa">Progress</a>
</li>
</ul>
</li>
Expand Down Expand Up @@ -364,7 +375,7 @@ <h4>Declaration</h4>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
<p>Invalid email provided for <code><a href="../Structs/User.html">User</a></code>.</p>
<p>Invalid email provided for <code>User</code>.</p>

</div>
<div class="declaration">
Expand All @@ -385,9 +396,9 @@ <h4>Declaration</h4>
<li class="item">
<div>
<code>
<a name="/s:9SwiftSMTP9SMTPErrorO11descriptionSSv"></a>
<a name="/s:9SwiftSMTP9SMTPErrorO11descriptionSSvp"></a>
<a name="//apple_ref/swift/Property/description" class="dashAnchor"></a>
<a class="token" href="#/s:9SwiftSMTP9SMTPErrorO11descriptionSSv">description</a>
<a class="token" href="#/s:9SwiftSMTP9SMTPErrorO11descriptionSSvp">description</a>
</code>
</div>
<div class="height-container">
Expand Down Expand Up @@ -417,7 +428,7 @@ <h4>Declaration</h4>
</article>
</div>
<section class="footer">
<p>&copy; 2018 <a class="link" href="" target="_blank" rel="external">IBM</a>. All rights reserved. (Last updated: 2018-04-23)</p>
<p>&copy; 2018 <a class="link" href="" target="_blank" rel="external">IBM</a>. All rights reserved. (Last updated: 2018-04-30)</p>
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.9.0</a>, a <a class="link" href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
</section>
</body>
Expand Down
Loading

0 comments on commit b6ca1ea

Please sign in to comment.