Note that the sign of the timezone offset is the opposite of the sign of the params is a sequence ofĢ-tuples containing elements of the form (content-type, string-value). decode_params ( params ) ¶ĭecode parameters list according to RFC 2231. RFC 2231 header is not known by Python it defaults to 'us-ascii'.įor convenience, if the value passed to collapse_rfc2231_value() is notĪ tuple, it should be a string and it is returned unquoted. Optionalįallback_charset specifies the character set to use if the one in the Optional errors is passed to the errors argument of str’sĮncode() method it defaults to 'replace'. collapse_rfc2231_value() turns this into a unicode When a header parameter is encoded in RFC 2231 format, collapse_rfc2231_value ( value, errors = 'replace', fallback_charset = 'us-ascii' ) ¶ Is not, the string is encoded using the empty string for language. Language, if given is the character set name and language name to use. encode_rfc2231 ( s, charset = None, language = None ) ¶Įncode the string s according to RFC 2231. decode_rfc2231 ( s ) ¶ĭecode the string s according to RFC 2231. This provides a way to generate standards conformant HTTP True, in which case the string GMT is used instead of the numeric If it is an aware timezone with offset zero, then usegmt may be set to If it is an aware datetime, then the numeric timezone offset is used. Source timezone”, and the conventional -0000 is used for the timezone. If it isĪ naive datetime, it is assumed to be “UTC with no information about the Like formatdate, but the input is a datetime instance.
This only applies when localtime isįalse. Needed for some protocols (such as HTTP). Timezone as an ascii string GMT, rather than a numeric -0000. Optional usegmt is a flag that when True, outputs a date string with the Returns a date relative to the local timezone instead of UTC, properly takingĭaylight savings time into account. Optional localtime is a flag that when True, interprets timeval, and
Time.gmtime() and time.localtime(), otherwise the current time is Optional timeval if given is a floating point time value as accepted by Offset, the datetime will be an aware datetime with the If the input date has any other valid timezone Time in UTC but with no indication of the actual source timezone of the If the input date has a timezone of -0000, the datetime will be a naiveĭatetime, and if the date is conforming to the RFCs it will represent a Otherwise ValueError is raised if date contains an invalid value suchĪs an hour greater than 23 or a timezone offset not between -24 and 24 hours. Parsedate(), but on success returns a datetime Note that indexes 6, 7, and 8 of the result tuple are not usable. Has no timezone, the last element of the tuple returned is 0, which represents (which is the official term for Greenwich Mean Time) 1. Time.mktime(), and the tenth is the offset of the date’s timezone from UTC Performs the same function as parsedate(), but returns either None orĪ 10-tuple the first 9 elements make up a tuple that can be passed directly to Note that indexes 6,ħ, and 8 of the result tuple are not usable. Time.mktime() otherwise None will be returned. The date, parsedate() returns a 9-tuple that can be passed directly to date is a string containing an RFC 2822ĭate, such as "Mon, 19:12:08 -0500". Mailers don’t follow that format as specified, so parsedate() tries to parsedate ( date ) ¶Īttempts to parse a date according to the rules in RFC 2822. get_all ( 'resent-cc', ) all_recipients = getaddresses ( tos + ccs + resent_tos + resent_ccs ) email.utils. get_all ( 'resent-to', ) resent_ccs = msg. Can be an instance of str or aįrom email.utils import getaddresses tos = msg. Optional charset is the character set that will be used in the RFC 2047Įncoding of the realname if the realname contains non-ASCIIĬharacters. If the first element of pair is false, then the The inverse of parseaddr(), this takes a 2-tuple of the form (realname, email_address) and returns the string value suitable for a To orĬc header. Returns a tuple of that information, unless the parseįails, in which case a 2-tuple of ('', '') is returned. Parse address – which should be the value of some address-containing field suchĪs To or Cc – into its constituent realname andĮmail address parts.
Likewise if str ends andīegins with angle brackets, they are stripped off. If str ends andīegins with double quotes, they are stripped off. Return a new string which is an unquoted version of str. Return a new string with backslashes in str replaced by two backslashes, andĭouble quotes replaced by backslash-double quote.
Is no need to directly use these with the new API, since the parsing andįormatting they provide is done automatically by the header parsing machinery The remaining functions are part of the legacy ( Compat32) email API. Changed in version 3.2: Added the domain keyword.