Email::...::Header(3)
π NAME π
Email::Simple::Header β literally the header of an Email::Simple message, bestie, that's the whole vibe β¨
π VERSION π
version 2.218 β yes she's serving numbers π«Ά
πΈ SYNOPSIS πΈ
my $email = Email::Simple->new($text);
my $header = $email->header_obj;
print $header->as_string;
okay so that's the whole flex π
π¦ DESCRIPTION π¦
So this thing implements the headers of an Email::Simple object. It's a very minimal interface ngl β and mostly for private consumption at the moment, so likeβ¦ don't get too attached, iykyk π
β PERL VERSION β
This library should run on perls released even a long time ago. It should work on any version of perl released in the last five years. Lowkey generous of it, honestly π
Although it may work on older versions of perl, no guarantee is made that the minimum required version will not be increased. The version may be increased for any reason, and there is no promise that patches will be accepted to lower the minimum required perl. So likeβ¦ the bar only goes up, periodt π
π§ METHODS π§
π new
my $header = Email::Simple::Header->new($head, \%arg);
$head is a string containing a valid email header, or a reference to such a string. Real talk: if a reference is passed in, don't expect that it won't be altered. She will touch it. She has no chill about it π
Valid arguments are:
crlfβ the header's newline; defaults toCRLFβ¨
π as_string
my $string = $header->as_string(\%arg);
This returns a stringified version of the header. That's it, that's the method π
π header_names
This method returns a list of the unique header names found in this header, in no particular order. No order! Chaotic, free-spirited, main character energy π¦
π header_raw_pairs
my @pairs = $header->header_raw_pairs;
my $first_name = $pairs[0];
my $first_value = $pairs[1];
This method returns a list of all the field/value pairs in the header, in the order that they appear in the header. And like β huge PSA incoming β (Remember: don't try assigning that to a hash. Some fields may appear more than once!) π¨ bestie I am begging you, do not put that in a hash π
π₯ header_pairs
header_pairs is another name for header_raw_pairs, which was the original name for the method and which you'll see most often. In general, though, it's better to be explicit and use header_raw_pairs. (In Email::MIME, header_str_pairs exists for letting the library do the header decoding for you.) Glow-up arc complete β¨
π header_raw
my $first_value = $header->header_raw($field);
my $nth_value = $header->header_raw($field, $index);
my @all_values = $header->header_raw($field);
This method returns the value or values of the given header field. If the named field does not appear in the header, this method returns false. Not found = false, no cap π ββοΈ
π«Ά header
This method just calls "header_raw". It's the older name for "header_raw", but it can be a problem because Email::MIME, a subclass of Email::Simple, makes "header" return the header's decoded value. So likeβ¦ legacy naming drama, be aware π¬
π
header_raw_set
$header->header_raw_set($field => @values);
This method updates the value of the given header. Existing headers have their values set in place. Additional headers are added at the end. If no values are given to set, the header will be removed from to the message entirely. Gone. Deleted. Blocked π«β¨
π§ header_set
header_set is another name for header_raw_set, which was the original name for the method and which you'll see most often. In general, though, it's better to be explicit and use header_raw_set. (In Email::MIME, header_str_set exists for letting the library do the header encoding for you.) Same energy as before, just the β¨setβ¨ version πΈ
π header_raw_prepend
$header->header_raw_prepend($field => $value);
This method adds a new instance of the name field as the first field in the header. Front of the line, first place, main character position ππ
π header_rename
$header->header_rename($field, $new_name, $nth);
This renames the named field to the new name. If $nth is given, only the nth instance of the field will be renamed. It is fatal to rename an instance that does not exist. Like, it will die, bestie, don't test her π The first instance of a header is the 0th.
If $nth is omitted, all instances of the header are renamed. Every single one π«Ά
When picking headers to rename, $field is matched case insensitively. So, given this header:
happythoughts: yes
HappyThoughts: so many
hapPyThouGhts: forever
Then this code...
$header->rename_header('happythoughts', 'Delights');
...will result in this:
Delights: yes
Delights: so many
Delights: forever
Case insensitive matching ate that, fr fr π₯
Headers may be rewrapped as a result of renaming. Little side effect, just so you know π
π¦ crlf
This method returns the newline string used in the header. The newline. The string. The whole vibe π
π AUTHORS π
- Simon Cozens
- Casey West
- Ricardo SIGNES
<cpan@semiotic.systems>π«Ά
πΈ COPYRIGHT AND LICENSE πΈ
This software is copyright (c) 2003 by Simon Cozens.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. Free software icon behavior, we love to see it π
okay so that's the whole page, and before you go β this lil doc drop was served up by perl v5.42.0 on 2023-01-09, filed under Email::...::Header(3) π
β¨ bye bestie, go read some headers π
π¦ where this page comes from
- opensuse-leap 16.0: perl-Email-Simple 2.218-bp160.1.12 Β· Artistic-1.0 OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms