File tree Expand file tree Collapse file tree 5 files changed +115
-3
lines changed Expand file tree Collapse file tree 5 files changed +115
-3
lines changed Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ import RFC_6531
66extension EmailAddress {
77 /// Initialize from RFC5322
88 public init ( rfc5322: RFC_5322 . EmailAddress ) throws {
9- self . rfc5321 = try ? rfc5322 . toRFC5321 ( )
9+ self . rfc5321 = try ? RFC_5321 . EmailAddress ( rfc5322 )
1010 self . rfc5322 = rfc5322
1111 self . rfc6531 = try {
1212 guard
Original file line number Diff line number Diff line change @@ -6,8 +6,8 @@ import RFC_6531
66extension EmailAddress {
77 /// Initialize from RFC6531
88 public init ( rfc6531: RFC_6531 . EmailAddress ) {
9- self . rfc5321 = try ? rfc6531 . toRFC5321 ( )
10- self . rfc5322 = try ? rfc6531 . toRFC5322 ( )
9+ self . rfc5321 = try ? RFC_5321 . EmailAddress ( rfc6531 )
10+ self . rfc5322 = try ? RFC_5322 . EmailAddress ( rfc6531 )
1111 self . rfc6531 = rfc6531
1212 self . displayName = rfc6531. displayName
1313 }
Original file line number Diff line number Diff line change 1+ import Foundation
2+ import RFC_5321
3+ import RFC_5322
4+
5+ extension RFC_5321 . EmailAddress {
6+ /// Initialize from RFC 5322 email address
7+ ///
8+ /// Converts an RFC 5322 (Internet Message Format) email address to RFC 5321 (SMTP) format.
9+ /// RFC 5321 has more restrictive rules than RFC 5322.
10+ ///
11+ /// - Parameter rfc5322: The RFC 5322 email address to convert
12+ /// - Throws: If the address contains characters or patterns not allowed in RFC 5321
13+ public init ( _ rfc5322: RFC_5322 . EmailAddress ) throws {
14+ try self . init (
15+ displayName: rfc5322. displayName,
16+ localPart: . init( rfc5322. localPart. stringValue) ,
17+ domain: rfc5322. domain
18+ )
19+ }
20+ }
21+
22+ extension RFC_5322 . EmailAddress {
23+ /// Initialize from RFC 5321 email address
24+ ///
25+ /// Converts an RFC 5321 (SMTP) email address to RFC 5322 (Internet Message Format).
26+ /// RFC 5322 allows a superset of RFC 5321, so this conversion always succeeds.
27+ ///
28+ /// - Parameter rfc5321: The RFC 5321 email address to convert
29+ /// - Throws: If the local part cannot be represented in RFC 5322 format
30+ public init ( _ rfc5321: RFC_5321 . EmailAddress ) throws {
31+ try self . init (
32+ displayName: rfc5321. displayName,
33+ localPart: . init( rfc5321. localPart. stringValue) ,
34+ domain: rfc5321. domain
35+ )
36+ }
37+ }
Original file line number Diff line number Diff line change 1+ import Foundation
2+ import RFC_1123
3+ import RFC_5321
4+ import RFC_6531
5+
6+ extension RFC_5321 . EmailAddress {
7+ /// Initialize from RFC 6531 email address
8+ ///
9+ /// Converts an RFC 6531 (SMTPUTF8) internationalized email address to RFC 5321 (SMTP) format.
10+ /// Only works for addresses that use ASCII characters only.
11+ ///
12+ /// - Parameter rfc6531: The RFC 6531 email address to convert
13+ /// - Throws: If the address contains non-ASCII characters or patterns not allowed in RFC 5321
14+ public init ( _ rfc6531: RFC_6531 . EmailAddress ) throws {
15+ try self . init (
16+ displayName: rfc6531. displayName,
17+ localPart: . init( rfc6531. localPart. stringValue) ,
18+ domain: . init( rfc6531. domain. name)
19+ )
20+ }
21+ }
22+
23+ extension RFC_6531 . EmailAddress {
24+ /// Initialize from RFC 5321 email address
25+ ///
26+ /// Converts an RFC 5321 (SMTP) email address to RFC 6531 (SMTPUTF8) format.
27+ /// RFC 6531 is a superset of RFC 5321, so this conversion always succeeds.
28+ ///
29+ /// - Parameter rfc5321: The RFC 5321 email address to convert
30+ /// - Throws: If the conversion fails
31+ public init ( _ rfc5321: RFC_5321 . EmailAddress ) throws {
32+ try self . init (
33+ displayName: rfc5321. displayName,
34+ localPart: . init( rfc5321. localPart. stringValue) ,
35+ domain: rfc5321. domain
36+ )
37+ }
38+ }
Original file line number Diff line number Diff line change 1+ import Foundation
2+ import RFC_5322
3+ import RFC_6531
4+
5+ extension RFC_5322 . EmailAddress {
6+ /// Initialize from RFC 6531 email address
7+ ///
8+ /// Converts an RFC 6531 (SMTPUTF8) internationalized email address to RFC 5322 (Internet Message Format).
9+ /// Only works for addresses that use ASCII characters only.
10+ ///
11+ /// - Parameter rfc6531: The RFC 6531 email address to convert
12+ /// - Throws: If the address contains non-ASCII characters or patterns not allowed in RFC 5322
13+ public init ( _ rfc6531: RFC_6531 . EmailAddress ) throws {
14+ try self . init (
15+ displayName: rfc6531. displayName,
16+ localPart: . init( rfc6531. localPart. stringValue) ,
17+ domain: rfc6531. domain
18+ )
19+ }
20+ }
21+
22+ extension RFC_6531 . EmailAddress {
23+ /// Initialize from RFC 5322 email address
24+ ///
25+ /// Converts an RFC 5322 (Internet Message Format) email address to RFC 6531 (SMTPUTF8) format.
26+ /// RFC 6531 is a superset of RFC 5322, so this conversion always succeeds.
27+ ///
28+ /// - Parameter rfc5322: The RFC 5322 email address to convert
29+ /// - Throws: If the conversion fails
30+ public init ( _ rfc5322: RFC_5322 . EmailAddress ) throws {
31+ try self . init (
32+ displayName: rfc5322. displayName,
33+ localPart: . init( rfc5322. localPart. stringValue) ,
34+ domain: rfc5322. domain
35+ )
36+ }
37+ }
You can’t perform that action at this time.
0 commit comments