Skip to content
Open
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
7 changes: 2 additions & 5 deletions Sources/MailCore/Extensions/Message+SMTP.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,12 @@ extension Mailer.Message {
let ccUsers = (cc ?? []).map({ Mail.User(email: $0) })
let bccUsers = (bcc ?? []).map({ Mail.User(email: $0) })

let attachments: [Attachment]
var attachments: [Attachment] = self.attachments ?? []
if let html = html {
attachments = [Attachment(htmlContent: html)]
} else {
attachments = []
attachments.append(Attachment(htmlContent: html))
}

let mail = Mail(from: fromUser, to: [toUser], cc: ccUsers, bcc: bccUsers, subject: subject, text: text, attachments: attachments)
return mail
}

}
4 changes: 3 additions & 1 deletion Sources/MailCore/MailCore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,18 @@ public class Mailer: MailerService {
public let subject: String
public let text: String
public let html: String?
public let attachments: [Attachment]?

/// Message init
public init(from: String, to: String, cc: [String]? = nil, bcc: [String]? = nil, subject: String, text: String, html: String? = nil) {
public init(from: String, to: String, cc: [String]? = nil, bcc: [String]? = nil, subject: String, text: String, html: String? = nil, attachments: [Attachment]? = nil) {
self.from = from
self.to = to
self.cc = cc
self.bcc = bcc
self.subject = subject
self.text = text
self.html = html
self.attachments = attachments
}
}

Expand Down