Hedwig
public struct Hedwig
Hedwig is the manager type of Hedwig framework. You can initialize an instance with common SMTP config and then send an email with it.
-
Initialize a Hedwig instance with SMTP config.
Note
Initializing a
Hedwiginstance will not do the actual connecting work. It will not try to connect to server until you send a mail.Declaration
Parameters
hostNameHostname of your SMTP server. The host name should not include any scheme. For example,
smtp.example.com
is a valid host name.userUser name used to auth with SMTP server. Pass
nilto this parameter if there is no need to auth with your server.passwordPassword used to auth with SMTP server. Pass
nilto this parameter if there is no need to auth with your server.portPort number which Hedwig should connect to. Default is
nil, which means Hedwig will determine the port for you according tosecureparameter and use the standard port.secureSecurity level used when communicating with server. Default is
.tls.validationValidation used when setup a secure connection with server.
domainNameThe clinet domain name used when communicating with server. Default is
localhostauthMethodsAuth methods accepted in client when auth with server. By default all auth methods (.plain, .cramMD5, .login, .xOauth2) in Hedwig are supported.
-
Send a single email.
Declaration
Swift
public func send(_ mail: Mail, completion: ((Error?) -> Void)? = nil)Parameters
mailThe email which will be sent.
completionCallback when sending finishes, with an optional
Errorto indicate whether there is an error happened while sending. If the mail is sent successfully, callback parameter would benil. -
Send an array of emails.
Note
Note:
- If a failure is encountered when while sending multiple mails, the
whole sending process will not stop until all pending mails are sent.
Each mail sending will trigger an invocation of
progress, and when all mails sending finish,completionhandler will be called. - The parameter of
progressblock contains the mail and an optionalError. If the mail is sent successfully, the error parameter would benil. Otherwise, it contains the error type. - The first parameter of
completionis an array of sucessully sent mails, while the second is an array of failed mails and corresponding errors for each. - This method will queue the
mailsand send them one by one. If you need to send mails in a concurrent way, callsend(_:progress:completion:)again with another array of mails.
Declaration
Parameters
mailsThe emails which will be sent.
progressCallback when an email sending finishes.
completionCallback when all emails sending finished.
- If a failure is encountered when while sending multiple mails, the
whole sending process will not stop until all pending mails are sent.
Each mail sending will trigger an invocation of
View on GitHub
Install in Dash
Hedwig Struct Reference