All Projects → LiveUI → Mailcore

LiveUI / Mailcore

Licence: mit
Emailing wrapper for Vapor 3 apps

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to Mailcore

Airform
Functional HTML forms for Front-End Developers.
Stars: ✭ 307 (+298.7%)
Mutual labels:  smtp, sendgrid, mailgun
mailcoach-support
Questions and support for Mailcoach
Stars: ✭ 32 (-58.44%)
Mutual labels:  mailgun, smtp, sendgrid
go-mail
📧 A cross platform mail driver for GoLang. Featuring Mailgun, Postal, Postmark, SendGrid, SparkPost & SMTP.
Stars: ✭ 169 (+119.48%)
Mutual labels:  mailgun, smtp, sendgrid
Mailer
A light-weight, modular, message representation and mail delivery framework for Python.
Stars: ✭ 225 (+192.21%)
Mutual labels:  smtp, sendgrid, mailgun
Magento2 Gmail Smtp App
Configure Magento 2 to send email using Google App, Gmail, Amazon Simple Email Service (SES), Microsoft Office365 and many other SMTP (Simple Mail Transfer Protocol) servers
Stars: ✭ 281 (+264.94%)
Mutual labels:  smtp, sendgrid, mailgun
Fluentemail
All in one email sender for .NET. Supports popular senders (SendGrid, MailGun, etc) and Razor templates.
Stars: ✭ 1,888 (+2351.95%)
Mutual labels:  smtp, sendgrid, mailgun
wemail
Send Affordable Bulk Email Campaign Through WordPress
Stars: ✭ 19 (-75.32%)
Mutual labels:  mailgun, smtp, sendgrid
Mailgun
📧 Service to assist with sending emails from Vapor apps
Stars: ✭ 82 (+6.49%)
Mutual labels:  vapor, mailgun
MailHookBundle
A bundle to catch API webhook from different mail service
Stars: ✭ 36 (-53.25%)
Mutual labels:  mailgun, sendgrid
Wp Phpmailer
Provides a clean and simple way to configure the WordPress-bundled PHPMailer library, allowing you to quickly get started sending mail through a local or cloud based service of your choice
Stars: ✭ 46 (-40.26%)
Mutual labels:  smtp, sendgrid
mailer
Simple Email Sending Client for Mailgun & Sendgrid services in crystal
Stars: ✭ 16 (-79.22%)
Mutual labels:  mailgun, sendgrid
sendgrid
SendGrid-powered mail backend for Vapor
Stars: ✭ 66 (-14.29%)
Mutual labels:  vapor, sendgrid
Django Anymail
Django email backends and webhooks for Amazon SES, Mailgun, Mailjet, Postmark, SendGrid, Sendinblue, SparkPost and more
Stars: ✭ 1,109 (+1340.26%)
Mutual labels:  sendgrid, mailgun
Notify
A dead simple Go library for sending notifications to various messaging services.
Stars: ✭ 727 (+844.16%)
Mutual labels:  sendgrid, mailgun
Slmmail
Send mail from Laminas or Mezzio using external mail services.
Stars: ✭ 106 (+37.66%)
Mutual labels:  sendgrid, mailgun
SlmMail
Send mail from Laminas or Mezzio using external mail services.
Stars: ✭ 107 (+38.96%)
Mutual labels:  mailgun, sendgrid
Omnimail
Send email across all platforms using one interface
Stars: ✭ 325 (+322.08%)
Mutual labels:  sendgrid, mailgun
Laravel Mailbox
Catch incoming emails in your Laravel application
Stars: ✭ 783 (+916.88%)
Mutual labels:  sendgrid, mailgun
Azure Functions Billing
Azure Functions v2 with .NET Core - billing in serverless architecture.
Stars: ✭ 49 (-36.36%)
Mutual labels:  sendgrid
Hedwig
Send email to any SMTP server like a boss, in Swift and cross-platform
Stars: ✭ 1,096 (+1323.38%)
Mutual labels:  smtp

LiveUI MailCore

Slack Jenkins Platforms Swift Package Manager Swift 4 Vapor 3

Mailing wrapper for multiple mailing services like Mailgun, SendGrid or SMTP

Features

  • [x] Mailgun
  • [x] SendGrid
  • [x] SMTP
  • [ ] Attachments
  • [ ] Multiple emails sent at the same time
  • [x] Multiple recipint, CC & BCC fields

Install

Just add following line package to your Package.swift file.

.package(url: "https://github.com/LiveUI/MailCore.git", .branch("master"))

Usage

Usage is really simple mkey!

1/3) Configure

First create your client configuration:

Mailgun

let config = Mailer.Config.mailgun(key: "{mailgunApi}", domain: "{mailgunDomain}", region: "{mailgunRegion}")

SendGrid

let config = Mailer.Config.sendGrid(key: "{sendGridApiKey}")

SMTP

Use the SMTP struct as a handle to your SMTP server:

let smtp = SMTP(hostname: "smtp.gmail.com",     // SMTP server address
                   email: "[email protected]",     // username to login
                password: "password")           // password to login
                
let config = Mailer.Config.smtp(smtp)

SMTP using TLS

All parameters of SMTP struct:

let smtp = SMTP(hostname: String,
                   email: String,
                password: String,
                    port: Int32 = 465,
                  useTLS: Bool = true,
        tlsConfiguration: TLSConfiguration? = nil,
             authMethods: [AuthMethod] = [],
             accessToken: String? = nil,
              domainName: String = "localhost",
                 timeout: UInt = 10)
                 
let config = Mailer.Config.smtp(smtp)

2/3) Register service

Register and configure the service in your apps configure method.

Mailer(config: config, registerOn: &services)

Mailer.Config is an enum and you can choose from any integrated services to be used

3/3) Send an email

let mail = Mailer.Message(from: "[email protected]", to: "[email protected]", subject: "Oil spill", text: "Oooops I did it again", html: "<p>Oooops I did it again</p>")
return try req.mail.send(mail).flatMap(to: Response.self) { mailResult in
    print(mailResult)
    // ... Return your response for example
}

Testing

Mailcore provides a MailCoreTestTools framework which you can import into your tests to get MailerMock.

To register, and potentially override any existing "real" Mailer service, just initialize MailerMock with your services.

// Register
MailerMock(services: &services)

// Retrieve in your tests
let mailer = try! req.make(MailerService.self) as! MailerMock

MailerMock will store the last used result as well as the received message and request. Structure of the moct can be seen below:

public class MailerMock: MailerService {

    public var result: Mailer.Result = .success
    public var receivedMessage: Mailer.Message?
    public var receivedRequest: Request?

    // MARK: Initialization

    @discardableResult public init(services: inout Services) {
        services.remove(type: Mailer.self)
        services.register(self, as: MailerService.self)
    }

    // MARK: Public interface

    public func send(_ message: Mailer.Message, on req: Request) throws -> Future<Mailer.Result> {
        receivedMessage = message
        receivedRequest = req
        return req.eventLoop.newSucceededFuture(result: result)
    }

    public func clear() {
        result = .success
        receivedMessage = nil
        receivedRequest = nil
    }

}

Support

Join our Slack, channel #help-boost to ... well, get help :)

Enterprise AppStore

Core package for Einstore, a completely open source enterprise AppStore written in Swift!

Other core packages

  • EinstoreCore - AppStore core module
  • ApiCore - Base user & team management including forgotten passwords, etc ...

Implemented thirdparty providers

Code contributions

We love PR’s, we can’t get enough of them ... so if you have an interesting improvement, bug-fix or a new feature please don’t hesitate to get in touch. If you are not sure about something before you start the development you can always contact our dev and product team through our Slack.

Author

Ondrej Rafaj (@rafiki270 on Github, Twitter, LiveUI Slack and Vapor Slack)

License

MIT license, please see LICENSE file for more details.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].