{"id":13588393,"url":"https://github.com/onevcat/Hedwig","last_synced_at":"2025-04-08T03:33:53.331Z","repository":{"id":66259701,"uuid":"77430263","full_name":"onevcat/Hedwig","owner":"onevcat","description":"Send email to any SMTP server like a boss, in Swift and cross-platform","archived":false,"fork":false,"pushed_at":"2017-06-03T02:43:46.000Z","size":279,"stargazers_count":1118,"open_issues_count":8,"forks_count":66,"subscribers_count":31,"default_branch":"master","last_synced_at":"2024-10-29T20:50:56.560Z","etag":null,"topics":["cross-platform","mail","server","smtp","swift"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/onevcat.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2016-12-27T06:04:41.000Z","updated_at":"2024-09-22T16:42:04.000Z","dependencies_parsed_at":"2023-02-23T09:45:16.226Z","dependency_job_id":null,"html_url":"https://github.com/onevcat/Hedwig","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/onevcat%2FHedwig","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/onevcat%2FHedwig/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/onevcat%2FHedwig/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/onevcat%2FHedwig/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/onevcat","download_url":"https://codeload.github.com/onevcat/Hedwig/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223173030,"owners_count":17100161,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cross-platform","mail","server","smtp","swift"],"created_at":"2024-08-01T15:06:41.213Z","updated_at":"2024-11-06T07:31:32.798Z","avatar_url":"https://github.com/onevcat.png","language":"Swift","funding_links":[],"categories":["Swift"],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n\n\u003cimg src=\"https://cloud.githubusercontent.com/assets/1019875/21935666/b7f8af46-d9f1-11e6-85d7-1cb4bc025226.png\"/\u003e\n\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n\u003ca href=\"https://swift.org/package-manager/\"\u003e\u003cimg src=\"https://img.shields.io/badge/swift-3.0-brightgreen.svg\"/\u003e\u003c/a\u003e\n\u003ca href=\"https://travis-ci.org/onevcat/Hedwig\"\u003e\u003cimg src=\"https://img.shields.io/travis/onevcat/Hedwig/master.svg\"\u003e\u003c/a\u003e\n\u003ca href=\"https://swift.org/package-manager/\"\u003e\u003cimg src=\"https://img.shields.io/badge/platform-macos%20|%20Linux-blue.svg\"/\u003e\u003c/a\u003e\n\u003ca href=\"https://codecov.io/gh/onevcat/Hedwig\"\u003e\u003cimg src=\"https://codecov.io/gh/onevcat/Hedwig/branch/master/graph/badge.svg\"/\u003e\u003c/a\u003e\n\u003ca href=\"https://codebeat.co/projects/github-com-onevcat-hedwig\"\u003e\u003cimg alt=\"codebeat badge\" src=\"https://codebeat.co/badges/87196d17-29e4-4152-b24e-20eaab8d718b\" /\u003e\u003c/a\u003e\n\u003ca href=\"https://raw.githubusercontent.com/onevcat/Hedwig/master/LICENSE\"\u003e\u003cimg src=\"https://img.shields.io/cocoapods/l/Hedwig.svg?style=flat\"/\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n---\n\nHedwig is a Swift package which supplies a set of high level APIs to allow you sending email to an SMTP server easily. If you are planning to send emails from your next amazing Swift server app, Hedwig might be a good choice.\n\n## Features\n\n- [x] Connect to all SMTP servers, through whether plain, SSL or TLS (STARTTLS) port.\n- [x] Authentication with `PLAIN`, `CRAM-MD5`, `LOGIN` or `XOAUTH2`.\n- [x] Send email with HTML body and attachments.\n- [x] Customize validation method and mail header, to track your mail campaign.\n- [x] Queued mail sending, without blocking your app. You can even send mails concurrently.\n- [x] Works with Swift Package Manager, in the latest Swift syntax and cross-platform.\n- [x] Fully tested and [documented](https://onevcat.github.io/Hedwig/).\n\n## Installation\n\nAdd the url of this repo to your Package.swift:\n\n```swift\nimport PackageDescription\n\nlet package = Package(\n    name: \"YourAwesomeSoftware\",\n    dependencies: [\n        .Package(url: \"https://github.com/onevcat/Hedwig.git\", \n                 majorVersion: 1)\n    ]\n)\n```\n\nThen run `swift build` whenever you get prepared. (Also remember to grab a cup of coffee 😄)\n\nYou can find more information on how to use Swift Package Manager in Apple's [official page](https://swift.org/package-manager/).\n\n## Usage\n\n### Sending text only email\n\n```swift\nlet hedwig = Hedwig(hostName: \"smtp.example.com\", user: \"foo@bar.com\", password: \"password\")\nlet mail = Mail(\n        text: \"Across the great wall we can reach every corner in the world.\", \n        from: \"onev@onevcat.com\", \n        to: \"foo@bar.com\", \n        subject: \"Hello World\"\n)\n    \nhedwig.send(mail) { error in\n    if error != nil { /* Error happened */ }\n}\n```\n\n### Sending HTML email\n\n```swift\nlet hedwig = Hedwig(hostName: \"smtp.example.com\", user: \"foo@bar.com\", password: \"password\")\nlet attachment = Attachment(htmlContent: \"\u003chtml\u003e\u003cbody\u003e\u003ch1\u003eTitle\u003c/h1\u003e\u003cp\u003eContent\u003c/p\u003e\u003c/body\u003e\u003c/html\u003e\")\nlet mail = Mail(\n        text: \"Fallback text\", \n        from: \"onev@onevcat.com\", \n        to: \"foo@bar.com\", \n        subject: \"Title\", \n        attachments: [attachment]\n)\nhedwig.send(mail) { error in\n    if error != nil { /* Error happened */ }\n}\n```\n\n### CC and BCC\n\n```swift\nlet hedwig = Hedwig(hostName: \"smtp.example.com\", user: \"foo@bar.com\", password: \"password\")\nlet mail = Mail(\n        text: \"Across the great wall we can reach every corner in the world.\", \n        from: \"onev@onevcat.com\", \n        to: \"foo@bar.com\",\n        cc: \"Wei Wang \u003conev@onevcat.com\u003e, tom@example.com\", // Addresses will be parsed for you\n        bcc: \"My Group: onev@onevcat.com, foo@bar.com;\",    // Even with group syntax\n        subject: \"Hello World\"\n)\nhedwig.send(mail) { error in\n    if error != nil { /* Error happened */ }\n}\n```\n\n### Using different SMTP settings (security layer, auth method and etc.)\n\n```swift\nlet hedwig = Hedwig(\n        hostName: \"smtp.example.com\", \n        user: \"foo@bar.com\", \n        password: \"password\",\n        port: 1234,     // Determined from secure layer by default\n        secure: .plain, // .plain (Port 25) | .ssl (Port 465) | .tls (Port 587) (default)\n        validation: .default, // You can set your own certificate/cipher/protocols\n        domainName: \"onevcat.com\", // Used when saying hello to STMP Server\n        authMethods: [.plain, .login] // Default: [.plain, .cramMD5, .login, .xOauth2]        \n)\n```\n\n### Send mails with inline image and other attachment\n\n```swift\nlet imagePath = \"/tmp/image.png\"\n// You can create an attachment from a local file path.\nlet imageAttachment = Attachment(\n        filePath: imagePath, \n        inline: true, \n        // Add \"Content-ID\" if you need to embed this image to another attachment.\n        additionalHeaders: [\"Content-ID\": \"hedwig-image\"] \n)\nlet html = Attachment(\n        htmlContent: \"\u003chtml\u003e\u003cbody\u003eA photo \u003cimg src=\\\"cid:hedwig-image\\\"/\u003e\u003c/body\u003e\u003c/html\u003e\", \n        // If imageAttachment only used embeded in HTML, I recommend to set it as related.\n        related: [imageAttachment]\n)\n\n// You can also create attachment from raw data.\nlet data = \"{\\\"key\\\": \\\"hello world\\\"}\".data(using: .utf8)!\nlet json = Attachment(\n        data: data, \n        mime: \"application/json\", \n        name: \"file.json\", \n        inline: false // Send as standalone attachment.\n)\n\nlet mail = Mail(\n        text: \"Fallback text\", \n        from: \"onev@onevcat.com\", \n        to: \"foo@bar.com\", \n        subject: \"Check the photo and json file!\",\n        attachments: [html, json]\nhedwig.send(mail) { error in\n    if error != nil { /* Error happened */ }\n}\n```\n\n### Send multiple mails\n\n```swift\nlet mail1: Mail = //...\nlet mail2: Mail = //...\n\nhedwig.send([mail1, mail2], \n        progress: { (mail, error) in\n            if error != nil { \n                print(\"\\(mail) failed. Error: \\(error)\") \n            }\n        },\n        completion: { (sent, failed) in\n            for mail in sent {\n                print(\"Sent mail: \\(mail.messageId)\")\n            }\n            \n            for (mail, error) in failed {\n                print(\"Mail \\(mail.messageId) errored: \\(error)\")\n            }\n        }\n)\n\n```\n\n## Help and Questions\n\nVisit the [documentation page](https://onevcat.github.io/Hedwig/) for full API reference.\n\nYou could also run the tests (`swift test`) to see more examples to know how to use Hedwig.\n\nIf you have found the framework to be useful, please consider a donation. Your kind contribution will help me afford more time on the project.\n\n\u003cp align=\"center\"\u003e\u003ca href='https://pledgie.com/campaigns/33218'\u003e\u003cimg alt='Click here to lend your support to: Hedwig and make a donation at pledgie.com !' src='https://pledgie.com/campaigns/33218.png?skin_name=chrome' border='0' \u003e\u003c/a\u003e\u003c/p\u003e\n\nOr you are a Bitcoin fan and want to treat me a cup of coffe, here is my wallet address:\n\n```\n1MqwfsxBJ5pJX4Qd2sRVhK3dKTQrWYooG5\n```\n\n### FAQ\n\n#### I cannot send mails with Gmail SMTP.\n\n\u003e Gmail uses an application specific password. You need to create one and use the specified password when auth. See [this](https://support.google.com/accounts/answer/185833?hl=en).\n\n#### I need to add/set some additonal header in the mail.\n\n\u003e Both `Mail` and `Attachment` accept customizing header fields. Pass your headers as `additionalHeaders` when creating the mail or attachment and Hedwig will handle it.\n\n#### Can I use it in iOS?\n\n\u003e At this time Swift Package Manager has no support for iOS, watchOS, or tvOS platforms. So the answer is no. But this framework is not using anything only in iOS (like UIKit), so as soon as Swift Package Manager supports iOS, you can use it there too.\n\n#### Tell me about the name and logo of Hedwig\n\n\u003e Yes, Hedwig (bird) was Harry Potter's pet Snowy Owl. The logo of Hedwig (this framework) is created by myself and it pays reverence to the novels and movies.\n\n#### Other questions\n\n\u003e Submit [an issue](https://github.com/onevcat/Hedwig/issues/new) if you find something wrong. Pull requests are warmly welcome, but I suggest to discuss first.\n\nYou can also follow and contact me on [Twitter](http://twitter.com/onevcat) or [Sina Weibo](http://weibo.com/onevcat).\n\n### Enjoy sending your emails\n\n![](https://cloud.githubusercontent.com/assets/1019875/21879961/8321a0ba-d8df-11e6-968d-41992815d2f6.gif)\n\n### License\n\nHedwig is released under the MIT license. See LICENSE for details.\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fonevcat%2FHedwig","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fonevcat%2FHedwig","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fonevcat%2FHedwig/lists"}