1 ConeĀ©
2
3MAIL::ADDRESS(3x) Cone: COnsole Newsreader And E MAIL::ADDRESS(3x)
4
5
6
8 mail::address - An E-mail address
9
11 #include <libmail/rfcaddr.H>
12
13 mail::address address("John Smith", "johnsmith@example.com");
14
15 std::string addr=address.getAddr();
16 std::string name=address.getName();
17
18 address.setAddr(addr);
19 address.setName(name);
20
21 std::string str=address.toString();
22
23 std::vector<mail::address> addressList;
24
25 std::string header= mail::address::toString("From: ", addressList,
26 size_t width=76);
27
28 size_t errorIndex;
29
30 bool error=mail::address::fromString(std::string addresses,
31 addressList,
32 errorIndex);
33
34 std::string stdAddr=address.getCanonAddress();
35
36 mail::address addr1, addr2;
37
38 bool same= addr1 == addr2;
39 bool notsame= addr1 != addr2;
40
42 mail::address represents a single E-mail address. An E-mail address
43 consists of the recipient's name, and the actual address in the format
44 of user@domain. The name and the address components may be accessed or
45 changed by getName(), getAddr(), setName() and setAddr() methods.
46
47 Note
48 mail::emailAddress would be a more appropriate class for most
49 situations. The name component used by getName() and setName()
50 methods is the Internet-format, MIME-encoded name.
51 mail::emailAddress is a subclass of mail::address, and provides
52 more convenient methods for working with the name component of an
53 E-mail address.
54
55 The toString and fromString methods, defined below, will take a
56 vector of either mail::emailAddress or mail::address objects, and
57 in all other ways both classes are freely interchangable, and may
58 be converted to one another.
59
60 The toString method converts an address to a text string formatted as
61 "name <user@domain>". A second toString function creates an E-mail
62 header that contains a comma-separated list of E-mail addresses. The
63 first parameter must be the header's name (with a trailing space
64 character); the second parameter is a reference to a vector of
65 mail::address objects. An optional third parameter sets the maximum
66 line width; the text string returned by toString will have newline
67 characters, if necessary to make sure that each line is shorter than
68 the specified maximum.
69
70 fromString does the opposite: it converts the contents of an E-mail
71 header to an array of mail::address objects. The first parameter is the
72 E-mail header's contents (withoutHeader-Name:). The second parameter is
73 a reference to a vector of mail::address objects. fromString returns
74 false if a fatal error has occured (out of memory, or something else).
75 errorIndex is normally set to string::npos. If the header cannot be
76 parsed; errorIndex is set to the index of the character in addresses
77 where a syntax error was found (the header is still parsed, and any
78 recognizable addresses are still saved in addressList).
79
80 addressList should be empty. Otherwise the addresses are appended to
81 addressList's existing contents.
82
83 Comparing addresses
84 The domain part of an E-mail address is case insensitive, however the
85 user part of an E-mail address is not case insensitive. It is up to
86 each individual domain whether or not the user part is case sensitive,
87 or not. Since it is not possible to determine whether user is case
88 sensitive; the getCanonAddress method returns the E-mail address as
89 user@domain, with only the domain part converted to lowercase.
90
91 The object also defines the equality and non-equality operators, which
92 compare the address portion of two mail::address objects (the name
93 portions are ignored), with the domain part of each domain being case
94 insensitive
95
97 mail::emailAddress(3x), mail::envelope(3x).
98
100 Sam Varshavchik
101
102
103
104ConeĀ© 08/25/2016 MAIL::ADDRESS(3x)