Giter Site home page Giter Site logo

addressparser's Introduction

AddressParser

This framework is a component of Hedwig, which is a cross platform Swift SMTP email client framework.

When sending an email, you need to specify the receipt address. The address field could be one of these forms below:

and even more and mixed...

If you need a complete solution of sending mails through SMTP by Swift, see Hedwig instead.

Installation

Add the url of this repo to your Package.swift:

import PackageDescription

let package = Package(
    name: "YourAwesomeSoftware",
    dependencies: [
        .Package(url: "https://github.com/onevcat/AddressParser.git", 
                 majorVersion: 1)
    ]
)

Then run swift build whenever you get prepared.

You could know more information on how to use Swift Package Manager in Apple's official page.

Usage

Use AddressParser.parse to parse an email string field to an array of Address. An Address struct contains the name of that address and an entry to indicate whether this is a mail address or a group.

import AddressParser

let _ = AddressParser.parse("[email protected]")
// [Address(name: "", entry: .mail("[email protected]"))]

let _ = AddressParser.parse("Wei Wang <[email protected]>")
// [Address(name: "Wei Wang", entry: .mail("[email protected]"))]

let _ = AddressParser.parse("[email protected], [email protected]")
// [
//     Address(name: "", entry: .mail("[email protected]"))
//     Address(name: "", entry: .mail("[email protected]"))
// ]

let _ = AddressParser.parse("My Group: [email protected], [email protected];")
// [
//     Address(name: "MyGroup", entry: .group([
//         Address(name: "", entry: .mail("[email protected]")),
//         Address(name: "", entry: .mail("[email protected]")),
//     ]))
// ]

License

MIT. See the LICENSE file.

addressparser's People

Contributors

onevcat avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

addressparser's Issues

Not build on Linux

The package does not build on ubuntu. The output is:

AddressParser.swift:31:19: error: use of undeclared type 'RegularExpression'
typealias Regex = RegularExpression
^~~~~~~~~~~~~~~~~

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.