### Swift: Manual Git Submodule Integration Source: https://github.com/igorrendulic/mimeemailparser/blob/master/README.md Instructions for manually adding MimeEmailParser to an Xcode project using Git submodules. This involves initializing a git repository if needed, adding the submodule, and then integrating the workspace. ```bash $ git init ``` ```bash $ git submodule add https://github.com/igorrendulic/MimeEmailParser.git ``` -------------------------------- ### Swift Package Manager Dependency Source: https://github.com/igorrendulic/mimeemailparser/blob/master/README.md Specifies how to add MimeEmailParser as a dependency in your Swift package's Package.swift file using Swift Package Manager. ```swift dependencies: [ .package(url: "https://github.com/igorrendulic/MimeEmailParser.git", .upToNextMajor(from: "1.0.0")) ] ``` -------------------------------- ### Swift: Parse Single Email Address Source: https://github.com/igorrendulic/mimeemailparser/blob/master/README.md Demonstrates how to use MimeEmailParser to parse a single email address. It can handle various formats, including those with display names and Q-encoded text. Errors during parsing are thrown. ```swift let address = try MimeEmailParser().parseSingleAddress(address: "jdeo@example.domain") ``` ```swift let address = try MimeEmailParser().parseSingleAddress(address: "John Doe ") ``` ```swift let address = try MimeEmailParser().parseSingleAddress(address: "john.q.public@example.com") ``` ```swift let address = try MimeEmailParser().parseSingleAddress(address: "John !@M@! Doe ") ``` ```swift // expected result: Address(Name: "Jörg Doe", Address: "joerg@example.com") let address = try MimeEmailParser().parseSingleAddress(address: "=?iso-8859-1?q?J=F6rg_Doe?= ") ``` ```swift // expected result: Address(Name: "Jörg Doe", Address: "joerg@example.com") let address = try MimeEmailParser().parseSingleAddress(address: "=?utf-8?q?J=C3=B6rg?= =?utf-8?q?Doe?= ") ``` -------------------------------- ### Decode RFC 2047 Encoded Words in Swift Source: https://github.com/igorrendulic/mimeemailparser/blob/master/README.md Decodes words encoded according to RFC 2047, which are often used in email headers to represent non-ASCII characters. The `decodeRFC2047Word` function handles both Base64 and Q-encoding schemes, returning the original string. This is crucial for displaying email headers correctly. ```swift // expcted result: This is a horsey: 🐎 let decoded = try rfc2047.decodeRFC2047Word(word: "=?UTF-8?B?VGhpcyBpcyBhIGhvcnNleTog8J+Qjg==?=") ``` -------------------------------- ### Parse Multiple Email Addresses in Swift Source: https://github.com/igorrendulic/mimeemailparser/blob/master/README.md Parses a string containing multiple email addresses, handling various formats including names, quoted strings, and international characters. The `parseAddressList` function returns an array of `Address` objects. It can handle complex cases like encoded names and grouped addresses. ```swift // expected result: [Address(Name: "Mary Smith", Address: "mary@x.test"),Address(Name: nil, Address: "jdoe@example.org"),Address(Name: "Who?", Address: "")] let addresses = try MimeEmailParser().parseAddressList(addresses: "Mary Smith , jdoe@example.org, Who? ") // expected results: Address(Name: "André Pirard", Address: "PIRARD@vm1.ulg.ac.be") let addresses = try MimeEmailParser().parseAddressList(addresses: "=?ISO-8859-1?Q?Andr=E9?= Pirard ") // expected result: [Address(Name: nil, Address: "addr1@example.com"), Address(Name: nil, Address: "addr2@example.com"), Address(Name: "John", Address: "addr3@example.com")] let addresses = try MimeEmailParser().parseAddressList(addresses: "Group1: ;, Group 2: addr2@example.com;, John ") ``` -------------------------------- ### Validate Email Addresses in Swift Source: https://github.com/igorrendulic/mimeemailparser/blob/master/README.md Validates a single email address using the `parseSingleAddress` function. It catches specific `EmailError` types, such as `noAngleAddr`, indicating potential formatting issues. The library supports validation against various RFC email format rules. ```swift do { _ = try MimeEmailParser().parseSingleAddress(address: "John Doe@foo.bar") } catch EmailError.noAngleAddr { // Handle specific error } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.