1Mail::Send(3) User Contributed Perl Documentation Mail::Send(3)
2
3
4
6 Mail::Send - Simple electronic mail interface
7
9 require Mail::Send;
10
11 $msg = Mail::Send->new;
12 $msg = Mail::Send->new(Subject => 'example', To => 'timbo');
13
14 $msg->to('user@host');
15 $msg->to('user@host', 'user2@example.com');
16 $msg->subject('example subject');
17 $msg->cc('user@host');
18 $msg->bcc('someone@else');
19
20 $msg->set($header, @values);
21 $msg->add($header, @values);
22 $msg->delete($header);
23
24 # Launch mailer and set headers. The filehandle returned
25 # by open() is an instance of the Mail::Mailer class.
26 # Arguments to the open() method are passed to the Mail::Mailer
27 # constructor.
28
29 $fh = $msg->open; # some default mailer
30 $fh = $msg->open('sendmail'); # explicit
31 print $fh "Body of message";
32 $fh->close # complete the message and send it
33 or die "couldn't send whole message: $!\n";
34
36 Mail::Send creates e-mail messages without using the Mail::Header
37 knowledge, which means that all escaping and folding must be done by
38 you! Also: do not forget to escape leading dots. Simplicity has its
39 price.
40
41 When you have time, take a look at Mail::Transport which is part of the
42 MailBox suite.
43
45 Constructors
46 Mail::Send->new(PAIRS)
47 A list of header fields (provided as key-value PAIRS) can be used
48 to initialize the object, limited to the few provided as method:
49 "to", "subject", "cc", and "bcc". For other header fields, use
50 add().
51
52 Header fields
53 $obj->add($fieldname, @values)
54 Add values to the list of defined values for the $fieldname.
55
56 $obj->bcc(@values)
57 $obj->cc(@values)
58 $obj->delete($fieldname)
59 $obj->set($fieldname, @values)
60 The @values will replace the old values for the $fieldname.
61 Returned is the LIST of values after modification.
62
63 $obj->subject(@values)
64 $obj->to(@values)
65
66 Sending
67 $obj->open(%options)
68 The %options are used to initiate a mailer object via
69 Mail::Mailer::new(). Then Mail::Mailer::open() is called with the
70 knowledge collected in this "Mail::Send" object.
71
72 Be warned: this module implements raw smtp, which means that you
73 have to escape lines which start with a dot, by adding one in
74 front.
75
77 This module is part of the MailTools distribution,
78 http://perl.overmeer.net/mailtools/.
79
81 The MailTools bundle was developed by Graham Barr. Later, Mark
82 Overmeer took over maintenance without commitment to further
83 development.
84
85 Mail::Cap by Gisle Aas <aas@oslonett.no>. Mail::Field::AddrList by
86 Peter Orbaek <poe@cit.dk>. Mail::Mailer and Mail::Send by Tim Bunce
87 <Tim.Bunce@ig.co.uk>. For other contributors see ChangeLog.
88
90 Copyrights 1995-2000 Graham Barr <gbarr@pobox.com> and 2001-2017 Mark
91 Overmeer <perl@overmeer.net>.
92
93 This program is free software; you can redistribute it and/or modify it
94 under the same terms as Perl itself. See
95 http://www.perl.com/perl/misc/Artistic.html
96
97
98
99perl v5.34.0 2021-07-22 Mail::Send(3)