1Mail::Sender(3)       User Contributed Perl Documentation      Mail::Sender(3)
2
3
4

NAME

6       Mail::Sender - (DEPRECATED) module for sending mails with attachments
7       through an SMTP server
8

DEPRECATED

10       Mail::Sender is deprecated. Email::Sender is the go-to choice when you
11       need to send Email from Perl.  Go there, be happy!
12

SYNOPSIS

14         use Mail::Sender;
15
16         my $sender = Mail::Sender->new({
17           smtp => 'mail.yourdomain.com',
18           from => 'your@address.com'
19         });
20         $sender->MailFile({
21           to => 'some@address.com',
22           subject => 'Here is the file',
23           msg => "I'm sending you the list you wanted.",
24           file => 'filename.txt'
25         });
26

DESCRIPTION

28       Mail::Sender is deprecated. Email::Sender is the go-to choice when you
29       need to send Email from Perl.  Go there, be happy!
30
31       Mail::Sender provides an object-oriented interface to sending mails. It
32       directly connects to the mail server using IO::Socket.
33

ATTRIBUTES

35       Mail::Sender implements the following attributes.
36
37       * Please note that altering an attribute after object creation is best
38       handled with creating a copy using "$sender = $sender->new({attribute
39       => 'value'})".  To obtain the current value of an attribute, break all
40       the rules and reach in there! "my $val = $sender->{attribute};"
41
42   auth
43           # mutating single attributes could get costly!
44           $sender = $sender->new({auth => 'PLAIN'});
45           my $auth = $sender->{auth}; # reach in to grab
46
47       The SMTP authentication protocol to use to login to the server
48       currently the only ones supported are "LOGIN", "PLAIN", "CRAM-MD5" and
49       "NTLM".  Some protocols have module dependencies. "CRAM-MD5" depends on
50       Digest::HMAC_MD5 and "NTLM" on Authen::NTLM.
51
52       You may add support for other authentication protocols yourself.
53
54   auth_encoded
55           # mutating single attributes could get costly!
56           $sender = $sender->new({auth_encoded => 1});
57           my $auth_enc = $sender->{auth_encoded}; # reach in to grab
58
59       If set to a true value, Mail::Sender attempts to use TLS (encrypted
60       connection) whenever the server supports it and you have
61       IO::Socket::SSL and Net::SSLeay.
62
63       The default value of this option is true! This means that if
64       Mail::Sender can send the data encrypted, it will.
65
66   authdomain
67           # mutating single attributes could get costly!
68           $sender = $sender->new({authdomain => 'bar.com'});
69           my $domain = $sender->{authdomain}; # reach in to grab
70
71       The domain name; used optionally by the "NTLM" authentication. Other
72       authentication protocols may use other options as well. They should all
73       start with "auth" though.
74
75   authid
76           # mutating single attributes could get costly!
77           $sender = $sender->new({authid => 'username'});
78           my $username = $sender->{authid}; # reach in to grab
79
80       The username used to login to the server.
81
82   authpwd
83           # mutating single attributes could get costly!
84           $sender = $sender->new({authpwd => 'password'});
85           my $password = $sender->{authpwd}; # reach in to grab
86
87       The password used to login to the server.
88
89   bcc
90           # mutating single attributes could get costly!
91           $sender = $sender->new({bcc => 'foo@bar.com'});
92           $sender = $sender->new({bcc => 'foo@bar.com, bar@baz.com'});
93           $sender = $sender->new({bcc => ['foo@bar.com', 'bar@baz.com']});
94           my $bcc = $sender->{bcc}; # reach in to grab
95
96       Send a blind carbon copy to these addresses.
97
98   boundary
99           # mutating single attributes could get costly!
100           $sender = $sender->new({boundary => '--'});
101           my $boundary = $sender->{boundary}; # reach in to grab
102
103       The message boundary. You usually do not have to change this, it might
104       only come in handy if you need to attach a multi-part mail created by
105       Mail::Sender to your message as a single part. Even in that case any
106       problems are unlikely.
107
108   cc
109           # mutating single attributes could get costly!
110           $sender = $sender->new({cc => 'foo@bar.com'});
111           $sender = $sender->new({cc => 'foo@bar.com, bar@baz.com'});
112           $sender = $sender->new({cc => ['foo@bar.com', 'bar@baz.com']});
113           my $cc = $sender->{cc}; # reach in to grab
114
115       Send a carbon copy to these addresses.
116
117   charset
118           # mutating single attributes could get costly!
119           $sender = $sender->new({charset => 'UTF-8'});
120           my $charset = $sender->{charset}; # reach in to grab
121
122       The charset of the single part message or the body of the multi-part
123       one.
124
125   client
126           # mutating single attributes could get costly!
127           $sender = $sender->new({client => 'localhost.localdomain'});
128           my $client = $sender->{client}; # reach in to grab
129
130       The name of the client computer.
131
132       During the connection you send the mail server your computer's name. By
133       default Mail::Sender sends "(gethostbyname 'localhost')[0]". If that is
134       not the address your needs, you can specify a different one.
135
136   confirm
137           # only delivery, to the 'from' address
138           $sender = $sender->new({confirm => 'delivery'});
139           # only reading, to the 'from' address
140           $sender = $sender->new({confirm => 'reading'});
141           # both: to the 'from' address
142           $sender = $sender->new({confirm => 'delivery, reading'});
143           # delivery: to specified address
144           $sender = $sender->new({confirm => 'delivery: my.other@address.com'});
145           my $confirm = $sender->{confirm}; # reach in to grab
146
147       Whether you want to request reading or delivery confirmations and to
148       what addresses.
149
150       Keep in mind that confirmations are not guaranteed to work. Some
151       servers/mail clients do not support this feature and some users/admins
152       may have disabled it.  So it's possible that your mail was delivered
153       and read, but you won't get any confirmation!
154
155   createmessageid
156           # mutating single attributes could get costly!
157           $sender = $sender->new({createmessageid => sub {
158               my $from = shift;
159               my ($sec, $min, $hour, $mday, $mon, $year) = gmtime(time);
160               $mon++;
161               $year += 1900;
162
163               return sprintf "<%04d%02d%02d_%02d%02d%02d_%06d.%s>", $year, $mon, $mday,
164                   $hour, $min, $sec, rand(100000), $from;
165           }});
166           my $cm_id = $sender->{createmessageid}; # reach in to grab
167
168       This option allows you to overwrite the function that generates the
169       message IDs for the emails. The option gets the "pure" sender's address
170       as it's only parameter and is supposed to return a string. See the
171       "MessageID" in Mail::Sender method.
172
173       If you want to specify a message id you can also use the "messageid"
174       parameter for the "Open" in Mail::Sender, "OpenMultipart" in
175       Mail::Sender, "MailMsg" in Mail::Sender or "MailFile" in Mail::Sender
176       methods.
177
178   ctype
179           # mutating single attributes could get costly!
180           $sender = $sender->new({ctype => 'text/plain'});
181           my $type = $sender->{ctype}; # reach in to grab
182
183       The content type of a single part message or the body of the multi-part
184       one.
185
186       Please do not confuse these two. The "multipart" in Mail::Sender
187       parameter is used to specify the overall content type of a multi-part
188       message (for example any HTML document with inlined images) while
189       "ctype" is an ordinary content type for a single part message or the
190       body of a multi-part message.
191
192   debug
193           # mutating single attributes could get costly!
194           $sender = $sender->new({debug => '/path/to/debug/file.txt'});
195           $sender = $sender->new({debug => $file_handle});
196           my $debug = $sender->{debug}; # reach in to grab
197
198       All the conversation with the server will be logged to that file or
199       handle.  All lines in the file should end with "CRLF" (the Windows and
200       Internet format).
201
202       If you pass the path to the log file, Mail::Sender will overwrite it.
203       If you want to append to the file, you have to open it yourself and
204       pass the filehandle:
205
206           open my $fh, '>>', '/path/to/file.txt' or die "Can't open: $!";
207           my $sender = Mail::Sender->new({
208               debug => $fh,
209           });
210
211   debug_level
212           # mutating single attributes could get costly!
213           $sender = $sender->new({debug_level => 1});
214           # 1: only log server communication, skip all msg data
215           # 2: log server comm. and message headers
216           # 3: log server comm., message and part headers
217           # 4: log everything (default behavior)
218           my $level = $sender->{debug_level}; # reach in to grab
219
220       Only taken into account if the "debug" attribute is specified.
221
222   encoding
223           # mutating single attributes could get costly!
224           $sender = $sender->new({encoding => 'Quoted-printable'});
225           my $encoding = $sender->{encoding}; # reach in to grab
226
227       Encoding of a single part message or the body of a multi-part message.
228
229       If the text of the message contains some extended characters or very
230       long lines, you should use "encoding => 'Quoted-printable'" in the call
231       to "Open" in Mail::Sender, "OpenMultipart" in Mail::Sender, "MailMsg"
232       in Mail::Sender or "MailFile" in Mail::Sender.
233
234       If you use some encoding you should either use "SendEnc" in
235       Mail::Sender or encode the data yourself!
236
237   ESMPT
238           # mutating single attributes could get costly!
239           $sender = $sender->new({
240               ESMTP => {
241                   NOTIFY => 'SUCCESS,FAILURE,DELAY',
242                   RET => 'HDRS',
243                   ORCPT => 'rfc822;my.other@address.com',
244                   ENVID => 'iuhsdfobwoe8t237',
245               },
246           });
247           my $esmtp = $sender->{ESMTP}; # reach in to grab
248
249       This option contains data for SMTP extensions. For example, it allows
250       you to request delivery status notifications according to RFC1891
251       <https://tools.ietf.org/html/rfc1891>.  If the SMTP server you connect
252       to doesn't support this extension, the options will be ignored.  You do
253       not need to worry about encoding the "ORCPT" or "ENVID" parameters.
254
255       •   "ENVID" - Used to propagate an identifier for this message
256           transmission envelope, which is also known to the sender and will,
257           if present, be returned in any Delivery Status Notifications issued
258           for this transmission.
259
260       •   "NOTIFY" - To specify the conditions under which a delivery status
261           notification should be generated. Should be either "NEVER" or a
262           comma-separated list of "SUCCESS", "FAILURE" and "DELAY".
263
264       •   "ORCPT" - Used to convey the original (sender-specified) recipient
265           address.
266
267       •   "RET" - To request that Delivery Status Notifications containing an
268           indication of delivery failure either return the entire contents of
269           a message or only the message headers. Must be either "FULL" or
270           "HDRS".
271
272   fake_cc
273           # mutating single attributes could get costly!
274           $sender = $sender->new({fake_cc => 'foo@bar.com'});
275           my $fake_cc = $sender->{fake_cc}; # reach in to grab
276
277       The address that will be shown in headers. If not specified, the "cc"
278       in Mail::Sender attribute will be used.
279
280   fake_from
281           # mutating single attributes could get costly!
282           $sender = $sender->new({fake_from => 'foo@bar.com'});
283           my $fake_from = $sender->{fake_from}; # reach in to grab
284
285       The address that will be shown in headers. If not specified, the "from"
286       in Mail::Sender attribute will be used.
287
288   fake_to
289           # mutating single attributes could get costly!
290           $sender = $sender->new({fake_to => 'foo@bar.com'});
291           my $fake_to = $sender->{fake_to}; # reach in to grab
292
293       The recipient's address that will be shown in headers. If not
294       specified, the "to" in Mail::Sender attribute will be used.
295
296       If the list of addresses you want to send your message to is long or if
297       you do not want the recipients to see each other's address set the
298       "fake_to" in Mail::Sender parameter to some informative, yet bogus,
299       address or to the address of your mailing/distribution list.
300
301   from
302           # mutating single attributes could get costly!
303           $sender = $sender->new({from => 'foo@bar.com'});
304           my $from = $sender->{from}; # reach in to grab
305
306       The sender's email address.
307
308   headers
309           # mutating single attributes could get costly!
310           $sender = $sender->new({headers => 'Content-Type: text/plain'});
311           $sender = $sender->new({headers => {'Content-Type' => 'text/plain'}});
312           my $headers = $sender->{headers}; # reach in to grab
313
314       You may use this parameter to add custom headers into the message.  The
315       parameter may be either a string containing the headers in the right
316       format or a hash containing the headers and their values.
317
318   keepconnection
319           # mutating single attributes could get costly!
320           $sender = $sender->new({keepconnection => 1);
321           $sender = $sender->new({keepconnection => 0});
322           my $keepcon = $sender->{keepconnection}; # reach in to grab
323
324       If set to a true value, it causes the Mail::Sender to keep the
325       connection open for several messages. The connection will be closed if
326       you call the "Close" in Mail::Sender method with a true value or if you
327       call "Open" in Mail::Sender, "OpenMultipart" in Mail::Sender, "MailMsg"
328       in Mail::Sender or "MailFile" in Mail::Sender with the "smtp"
329       attribute. This means that if you want the object to keep the
330       connection, you should pass the "smtp" either to "new" in Mail::Sender
331       or only to the first "Open" in Mail::Sender, "OpenMultipart" in
332       Mail::Sender, "MailMsg" in Mail::Sender or "MailFile" in Mail::Sender!
333
334   multipart
335           # mutating single attributes could get costly!
336           $sender = $sender->new({multipart => 'Mixed'});
337           my $multi = $sender->{multipart}; # reach in to grab
338
339       The "MIME" subtype for the whole message ("Mixed/Related/Alternative").
340       You may need to change this setting if you want to send an HTML body
341       with some inline images, or if you want to post the message in plain
342       text as well as HTML (alternative).
343
344   on_errors
345           # mutating single attributes could get costly!
346           $sender = $sender->new({on_errors => 'undef'}); # return undef on error
347           $sender = $sender->new({on_errors => 'die'}); # raise an exception
348           $sender = $sender->new({on_errors => 'code'}); # return the negative error code (default)
349           # -1 = $smtphost unknown
350           # -2 = socket() failed
351           # -3 = connect() failed
352           # -4 = service not available
353           # -5 = unspecified communication error
354           # -6 = local user $to unknown on host $smtp
355           # -7 = transmission of message failed
356           # -8 = argument $to empty
357           # -9 = no message specified in call to MailMsg or MailFile
358           # -10 = no file name specified in call to SendFile or MailFile
359           # -11 = file not found
360           # -12 = not available in singlepart mode
361           # -13 = site specific error
362           # -14 = connection not established. Did you mean MailFile instead of SendFile?
363           # -15 = no SMTP server specified
364           # -16 = no From: address specified
365           # -17 = authentication protocol not accepted by the server
366           # -18 = login not accepted
367           # -19 = authentication protocol is not implemented
368           # -20 = all recipients were rejected by the server
369           # -21 = file specified as an attachment cannot be read
370           # -22 = failed to open the specified debug file for writing
371           # -23 = STARTTLS failed (for SSL or TLS encrypted connections)
372           # -24 = IO::Socket::SSL->start_SSL failed
373           # -25 = TLS required by the specified options, but the required modules are not available. Need IO::Socket::SSL and Net::SSLeay
374           # -26 = TLS required by the specified options, but the server doesn't support it
375           # -27 = unknown encoding specified for the mail body, part or attachment. Only base64, quoted-printable, 7bit and 8bit supported.
376           my $on_errors = $sender->{on_errors}; # reach in to grab
377           say $Mail::Sender::Error; # contains a textual description of last error.
378
379       This option allows you to affect the way Mail::Sender reports errors.
380       All methods return the $sender object if they succeed.
381
382       $Mail::Sender::Error "$sender->{'error'}" and "$sender->{'error_msg'}"
383       are set in all cases.
384
385   port
386           # mutating single attributes could get costly!
387           $sender = $sender->new({port => 25});
388           my $port = $sender->{port}; # reach in to grab
389
390       The TCP/IP port used form the connection. By default
391       "getservbyname('smtp', 'tcp')||25".  You should only need to use this
392       option if your mail server waits on a nonstandard port.
393
394   priority
395           # mutating single attributes could get costly!
396           $sender = $sender->new({priority => 1});
397           # 1. highest
398           # 2. high
399           # 3. normal
400           # 4. low
401           # 5. lowest
402           my $priority = $sender->{priority}; # reach in to grab
403
404       The message priority number.
405
406   replyto
407           # mutating single attributes could get costly!
408           $sender = $sender->new({replyto => 'foo@bar.com'});
409           my $replyto = $sender->{replyto}; # reach in to grab
410
411       The reply to address.
412
413   skip_bad_recipients
414           # mutating single attributes could get costly!
415           $sender = $sender->new({skip_bad_recipients => 1);
416           $sender = $sender->new({skip_bad_recipients => 0});
417           my $skip = $sender->{skip_bad_recipients}; # reach in to grab
418
419       If this option is set to false, or not specified, then Mail::Sender
420       stops trying to send a message as soon as the first recipient's address
421       fails. If it is set to a true value, Mail::Sender skips the bad
422       addresses and tries to send the message at least to the good ones. If
423       all addresses are rejected by the server, it reports a "All recipients
424       were rejected" message.
425
426       If any addresses were skipped, the "$sender->{'skipped_recipients'}"
427       will be a reference to a hash containing the failed address and the
428       server's response.
429
430   smtp
431           # mutating single attributes could get costly!
432           $sender = $sender->new({smtp => 'smtp.bar.com'});
433           my $smtp = $sender->{smtp}; # reach in to grab
434
435       The IP address or domain of your SMTP server.
436
437   ssl_...
438       The "ssl_version", "ssl_verify_mode", "ssl_ca_path", "ssl_ca_file",
439       "ssl_verifycb_name", "ssl_verifycn_schema" and "ssl_hostname" options
440       (if specified) are passed to "start_SSL" in IO::Socket::SSL. The
441       default version is "TLSv1" and verify mode is
442       "IO::Socket::SSL::SSL_VERIFY_NONE".
443
444       If you change the "ssl_verify_mode" to "SSL_VERIFY_PEER", you may need
445       to specify the "ssl_ca_file". If you have Mozilla::CA installed, then
446       setting it to "Mozilla::CA::SSL_ca_file()" may help.
447
448   subject
449           # mutating single attributes could get costly!
450           $sender = $sender->new({subject => 'An email is coming!'});
451           my $subject = $sender->{subject}; # reach in to grab
452
453       The subject of the message.
454
455   tls_allowed
456           # mutating single attributes could get costly!
457           $sender = $sender->new({tls_allowed => 1}); # true, default
458           $sender = $sender->new({tls_allowed => 0}); # false
459           my $tls = $sender->{tls_allowed}; # reach in to grab
460
461       If set to a true value, Mail::Sender will attempt to use TLS (encrypted
462       connection) whenever the server supports it.  This requires that you
463       have IO::Socket::SSL and Net::SSLeay.
464
465   tls_required
466           # mutating single attributes could get costly!
467           $sender = $sender->new({tls_required => 1}); # true, require TLS encryption
468           $sender = $sender->new({tls_required => 0}); # false, plain. default
469           my $required = $sender->{tls_required};
470
471       If you set this option to a true value, the module will fail if it's
472       unable to use TLS.
473
474   to
475           # mutating single attributes could get costly!
476           $sender = $sender->new({to => 'foo@bar.com'});
477           $sender = $sender->new({to => 'foo@bar.com, bar@baz.com'});
478           $sender = $sender->new({to => ['foo@bar.com', 'bar@baz.com']});
479           my $to = $sender->{to}; # reach in to grab
480
481       The recipient's addresses. This parameter may be either a comma
482       separated list of email addresses or a reference to a list of
483       addresses.
484

METHODS

486       Mail::Sender implements the following methods.
487
488   Attach
489           # set parameters in an ordered list
490           # -- description, ctype, encoding, disposition, file(s)
491           $sender = $sender->Attach(
492               'title', 'application/octet-stream', 'Base64', 'attachment; filename=*', '/file.txt'
493           );
494           $sender = $sender->Attach(
495               'title', 'application/octet-stream', 'Base64', 'attachment; filename=*',
496               ['/file.txt', '/file2.txt']
497           );
498           # OR use a hashref
499           $sender = $sender->Attach({
500               description => 'some title',
501               charset => 'US-ASCII', # default
502               encoding => 'Base64', # default
503               ctype => 'application/octet-stream', # default
504               disposition => 'attachment; filename=*', # default
505               file => ['/file1.txt'], # file names
506               content_id => '#', # for auto-increment number, or * for filename
507           });
508
509       Sends a file as a separate part of the mail message. Only in multi-part
510       mode.
511
512   Body
513           # set parameters in an ordered list
514           # -- charset, encoding, content-type
515           $sender = $sender->Body('US-ASCII', '7BIT', 'text/plain');
516           # OR use a hashref
517           $sender = $sender->Body({
518               charset => 'US-ASCII', # default
519               encoding => '7BIT', # default
520               ctype => 'text/plain', # default
521               msg => '',
522           });
523
524       Sends the head of the multi-part message body. You can specify the
525       charset and the encoding.
526
527   Cancel
528           $sender = $sender->Cancel;
529
530       Cancel an opened message.
531
532       "SendFile" in Mail::Sender and other methods may set
533       "$sender->{'error'}".  In that case "undef $sender" calls
534       "$sender->Cancel" not "$sender->Close"!!!
535
536   ClearErrors
537           $sender->ClearErrors();
538
539       Make the various error variables "undef".
540
541   Close
542           $sender->Close();
543           $sender->Close(1); # force override keepconnection
544
545       Close and send the email message. If you pass a true value to the
546       method the connection will be closed even if the "keepconnection" was
547       specified. You should only keep the connection open if you plan to send
548       another message immediately. And you should not keep it open for
549       hundreds of emails even if you do send them all in a row.
550
551       This method should be called automatically when destructing the object,
552       but you should not rely on it. If you want to be sure your message WAS
553       processed by the server, you SHOULD call "Close" in Mail::Sender
554       explicitly.
555
556   Connect
557       This method gets called automatically. Do not call it yourself.
558
559   Connected
560           my $bool = $sender->Connected();
561
562       Returns an "undef" or true value to let you know if you're connected to
563       the mail server.
564
565   EndPart
566           $sender = $sender->EndPart($ctype);
567
568       Closes a multi-part part.
569
570       If the $ctype is not present or evaluates to false, only the current
571       SIMPLE part is closed! Don't do that unless you are really sure you
572       know what you are doing.
573
574       It's best to always pass to the "->EndPart()" the content type of the
575       corresponding "->Part()".
576
577   GetHandle
578           $sender->Open({...});
579           my $handle = $sender->GetHandle();
580           $handle->print("Hello world.\n");
581           my ($mday,$mon,$year) = (localtime())[3,4,5];
582           $handle->print(sprintf("Today is %04d/%02d/%02d.", $year+1900, $mon+1, $mday));
583           close $handle;
584
585       Returns a file handle to which you can print the message or file to
586       attach. The data you print to this handle will be encoded as necessary.
587       Closing this handle closes either the message (for single part
588       messages) or the part.
589
590   MailFile
591           # set parameters in an ordered list
592           # -- from, reply-to, to, smtp, subject, headers, message, files(s)
593           $sender = $sender->MailFile('from@foo.com','reply-to@bar.com','to@baz.com')
594           # OR use a hashref -- see the attributes section for a
595           # list of appropriate parameters.
596           $sender = $sender->MailFile({file => ['/file1','/file2'], msg => "Message"});
597
598       Sends one or more files by mail. If a message in $sender is opened, it
599       gets closed and a new message is created and sent. $sender is then
600       closed.
601
602       The "file" parameter may be a string file name, a comma-separated list
603       of filenames, or an array reference of filenames.
604
605       Keep in mind that parameters like "ctype", "charset" and "encoding"
606       will be used for the attached file, not the body of the message. If you
607       want to specify those parameters for the body, you have to use
608       "b_ctype", "b_charset" and "b_encoding".
609
610   MailMsg
611           # set parameters in an ordered list
612           # -- from, reply-to, to, smtp, subject, headers, message
613           $sender = $sender->MailMsg('from@foo.com','reply-to@bar.com','to@baz.com')
614           # OR use a hashref -- see the attributes section for a
615           # list of appropriate parameters.
616           $sender = $sender->MailMsg({from => "foo@bar.com", msg => "Message"});
617
618       Sends a message. If a message in $sender is opened, it gets closed and
619       a new message is created and sent. $sender is then closed.
620
621   new
622           # Create a new sender instance with only the 'from' address
623           my $sender = Mail::Sender->new('from_address@bar.com');
624           # Create a new sender with any attribute above set in a hashref
625           my $sender = Mail::Sender->new({attribute => 'value', });
626           # Create a new sender as a copy of an existing one
627           my $copy = $sender->new({another_attr => 'bar',});
628
629       Prepares a sender. Any attribute can be set during instance creation.
630       This doesn't start any connection to the server. You have to use
631       "$sender->Open" or "$sender->OpenMultipart" to start talking to the
632       server.
633
634       The attributes are used in subsequent calls to "$sender->Open" and
635       "$sender->OpenMultipart". Each such call changes the saved variables.
636       You can set "smtp", "from" and other options here and then use the info
637       in all messages.
638
639   Open
640           # set parameters in an ordered list
641           # -- from, reply-to, to, smtp, subject, headers
642           $sender = $sender->Open('from@foo.com','reply-to@bar.com','to@baz.com');
643           # OR use a hashref -- see the attributes section for a
644           # list of appropriate parameters.
645           $sender = $sender->Open({to=>'to@baz.com', subject=>'Incoming!!!'});
646
647       Opens a new message. The only additional parameter that may not be
648       specified directly in "new" in Mail::Sender is "messageid". If you set
649       this option, the message will be sent with that "Message-ID", otherwise
650       a new Message ID will be generated out of the sender's address, current
651       date+time and a random number (or by the function you specified in the
652       "createmessageid" attribute).
653
654       After the message is sent "$sender->{messageid}" will contain the
655       Message-ID with which the message was sent.
656
657   OpenMultipart
658           # set parameters in an ordered list
659           # -- from, reply-to, to, smtp, subject, headers, boundary
660           $sender = $sender->OpenMultipart('from@foo.com','reply-to@bar.com');
661           # OR use a hashref -- see the attributes section for a
662           # list of appropriate parameters.
663           $sender = $sender->OpenMultipart({to=>'to@baz.com', subject=>'Incoming!!!'});
664
665       Opens a multipart message.
666
667   Part
668           # set parameters in an ordered list
669           # -- description, ctype, encoding, disposition, content_id, Message
670           $sender = $sender->Part(
671               'something', 'text/plain', '7BIT', 'attachment; filename="send.pl"'
672           );
673           # OR use a hashref -- see the attributes section for a
674           # list of appropriate parameters.
675           $sender = $sender->Part({
676               description => "desc",
677               ctype => "application/octet-stream", # default
678               encoding => '7BIT', # default
679               disposition => 'attachment', # default
680               content_id => '#', # for auto-increment number, or * for filename
681               msg => '', # You don't have to specify here, you may use SendEnc()
682                           # to add content to the part.
683           });
684
685       Prints a part header for the multipart message and (if specified) the
686       contents.
687
688   print
689       An alias for "SendEnc" in Mail::Sender.
690
691   QueryAuthProtocols
692           my @protocols = $sender->QueryAuthProtocols();
693           my @protocols = $sender->QueryAuthProtocols( $smtpserver);
694
695       Queries the server specified in the attributes or in the parameter to
696       this method for the authentication protocols it supports.
697
698   Send
699           $sender = $sender->Send(@strings);
700
701       Prints the strings to the socket. It doesn't add any line terminations
702       or encoding.  You should use "\r\n" as the end-of-line!
703
704       UNLESS YOU ARE ABSOLUTELY SURE YOU KNOW WHAT YOU ARE DOING YOU SHOULD
705       USE "SendEnc" in Mail::Sender INSTEAD!
706
707   SendEnc
708           $sender = $sender->SendEnc(@strings);
709
710       Prints the bytes to the socket. It doesn't add any line terminations.
711       Encodes the text using the selected encoding: "none | Base64 |
712       Quoted-printable".  You should use "\r\n" as the end-of-line!
713
714   SendEx
715           $sender = $sender->SendEx(@strings);
716
717       Prints the strings to the socket. Doesn't add any end-of-line
718       characters.  Changes all end-of-lines to "\r\n". Doesn't encode the
719       data!
720
721       UNLESS YOU ARE ABSOLUTELY SURE YOU KNOW WHAT YOU ARE DOING YOU SHOULD
722       USE "SendEnc" in Mail::Sender INSTEAD!
723
724   SendFile
725       Alias for "Attach" in Mail::Sender
726
727   SendLine
728           $sender = $sender->SendLine(@strings);
729
730       Prints the strings to the socket. Each byte string is terminated by
731       "\r\n". No encoding is done. You should use "\r\n" as the end-of-line!
732
733       UNLESS YOU ARE ABSOLUTELY SURE YOU KNOW WHAT YOU ARE DOING YOU SHOULD
734       USE "SendLineEnc" in Mail::Sender INSTEAD!
735
736   SendLineEnc
737           $sender = $sender->SendLineEnc(@strings);
738
739       Prints the strings to the socket and adds the end-of-line character at
740       the end.  Encodes the text using the selected encoding: "none | Base64
741       | Quoted-printable".
742
743       Do NOT mix up "Send" in Mail::Sender, "SendEx" in Mail::Sender,
744       "SendLine" in Mail::Sender, or "SendLineEx" in Mail::Sender with
745       "SendEnc" in Mail::Sender or "SendLineEnc" in Mail::Sender!  "SendEnc"
746       in Mail::Sender does some buffering necessary for correct Base64
747       encoding, and "Send" in Mail::Sender and "SendEx" in Mail::Sender are
748       not aware of that.
749
750       Usage of "Send" in Mail::Sender, "SendEx" in Mail::Sender, "SendLine"
751       in Mail::Sender, and "SendLineEx" in Mail::Sender in non "xBIT" parts
752       is not recommended. Using "Send(encode_base64($string))" may work, but
753       more likely it will not! In particular, if you use several such to
754       create one part, the data is very likely to get crippled.
755
756   SendLineEx
757           $sender = $sender->SendLineEnc(@strings);
758
759       Prints the strings to the socket. Adds an end-of-line character at the
760       end.  Changes all end-of-lines to "\r\n". Doesn't encode the data!
761
762       UNLESS YOU ARE ABSOLUTELY SURE YOU KNOW WHAT YOU ARE DOING YOU SHOULD
763       USE "SendLineEnc" in Mail::Sender INSTEAD!
764

FUNCTIONS

766       Mail::Sender implements the following functions.
767
768   GuessCType
769           my $ctype = Mail::Sender::GuessCType($filename, $filepath);
770
771       Guesses the content type based on the filename or the file contents.
772       This function is used when you attach a file and do not specify the
773       content type.  It is not exported by default!
774
775   MessageID
776           my $id = Mail::Sender::MessageID('from@foo.com');
777
778       Generates a "unique" message ID for a given from address.
779
780   ResetGMTdiff
781           Mail::Sender::ResetGMTdiff();
782
783       The module computes the local vs. GMT time difference to include in the
784       timestamps added into the message headers. As the time difference may
785       change due to summer savings time changes you may want to reset the
786       time difference occasionally in long running programs.
787

BUGS

789       I'm sure there are many. Please let me know if you find any.
790
791       The problem with multi-line responses from some SMTP servers (namely
792       qmail <http://www.qmail.org/top.html>) is solved at last.
793

SEE ALSO

795       Email::Sender
796
797       There are lots of mail related modules on CPAN. Be wise, use
798       Email::Sender!
799

AUTHOR

801       Jan Krynický <Jenda@Krynicky.cz> <http://Jenda.Krynicky.cz>
802

CONTRIBUTORS

804       •   Brian Blakley <bblakley@mp5.net>,
805
806       •   Chase Whitener <capoeirab@cpan.org>,
807
808       •   Ed McGuigan <itstech1@gate.net>,
809
810       •   John Sanche <john@quadrant.net>
811
812       •   Rodrigo Siqueira <rodrigo@insite.com.br>,
813
815       Copyright (c) 1997-2014 Jan Krynický <Jenda@Krynicky.cz>. All rights
816       reserved.
817
818       This program is free software; you can redistribute it and/or modify it
819       under the same terms as Perl itself.
820
821
822
823perl v5.32.1                      2021-01-27                   Mail::Sender(3)
Impressum