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

NAME

6       Mail::Sender - module for sending mails with attachments through an
7       SMTP server
8
9       Version 0.8.16
10

SYNOPSIS

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

DESCRIPTION

21       "Mail::Sender" provides an object oriented interface to sending mails.
22       It doesn't need any outer program. It connects to a mail server
23       directly from Perl, using Socket.
24
25       Sends mails directly from Perl through a socket connection.
26

new Mail::Sender

28        new Mail::Sender ([from [,replyto [,to [,smtp [,subject [,headers [,boundary]]]]]]])
29        new Mail::Sender {[from => 'somebody@somewhere.com'] , [to => 'else@nowhere.com'] [...]}
30
31       Prepares a sender. This doesn't start any connection to the server. You
32       have to use "$Sender-"Open> or "$Sender-"OpenMultipart> to start
33       talking to the server.
34
35       The parameters are used in subsequent calls to "$Sender-"Open> and
36       "$Sender-"OpenMultipart>. Each such call changes the saved variables.
37       You can set "smtp", "from" and other options here and then use the info
38       in all messages.
39
40   Parameters
41       from
42           ""=> the sender's e-mail address
43
44       fake_from
45           ""=> the address that will be shown in headers.
46
47           If not specified we use the value of "from".
48
49       replyto
50           ""=> the reply-to address
51
52       to  ""=> the recipient's address(es)
53
54           This parameter may be either a comma separated list of email
55           addresses or a reference to a list of addresses.
56
57       fake_to
58           ""=> the recipient's address that will be shown in headers.  If not
59           specified we use the value of "to".
60
61           If the list of addresses you want to send your message to is long
62           or if you do not want the recipients to see each other's address
63           set the "fake_to" parameter to some informative, yet bogus, address
64           or to the address of your mailing/distribution list.
65
66       cc  ""=> address(es) to send a copy (CC:) to
67
68       fake_cc
69           ""=> the address that will be shown in headers.
70
71           If not specified we use the value of "cc".
72
73       bcc ""=> address(es) to send a copy (BCC: or blind carbon copy).  these
74           addresses will not be visible in the mail!
75
76       smtp
77           ""=> the IP or domain address of your SMTP (mail) server
78
79           This is the name of your LOCAL mail server, do NOT try to contact
80           directly the adressee's mailserver! That would be slow and buggy,
81           your script should only pass the messages to the nearest mail
82           server and leave the rest to it. Keep in mind that the recipient's
83           server may be down temporarily.
84
85       port
86           ""=> the TCP/IP port used form the connection. By default
87           getservbyname('smtp', 'tcp')||25.  You should only need to use this
88           option if your mail server waits on a nonstandard port.
89
90       subject
91           ""=> the subject of the message
92
93       headers
94           ""=> the additional headers
95
96           You may use this parameter to add custon headers into the message.
97           The parameter may be either a string containing the headers in the
98           right format or a hash containing the headers and their values.
99
100       boundary
101           ""=> the message boundary
102
103           You usualy do not have to change this, it might only come in handy
104           if you need to attach a multipart mail created by Mail::Sender to
105           your message as a single part.  Even in that case any problems are
106           unlikely.
107
108       multipart
109           ""=> the MIME subtype for the whole message
110           (Mixed/Related/Alternative)
111
112           You may need to change this setting if you want to send a HTML body
113           with some inline images, or if you want to post the message in
114           plain text as well as HTML (alternative). See the examples at the
115           end of the docs.  You may also use the nickname "subtype".
116
117           Please keep in mind though that it's not currently possible to
118           create nested parts with Mail::Sender.  If you need that level of
119           control you should try MIME::Lite.
120
121       ctype
122           ""=> the content type of a single part message
123
124           Please do not confuse these two. The 'multipart' parameter is used
125           to specify the overall content type of a multipart message (for
126           example a HTML document with inlined images) while ctype is an
127           ordinary content type for a single part message. For example a HTML
128           mail message without any inlines.
129
130       encoding
131           ""=> encoding of a single part message or the body of a multipart
132           message.
133
134           If the text of the message contains some extended characters or
135           very long lines you should use 'encoding => "Quoted-printable"' in
136           the call to Open(), OpenMultipart(), MailMsg() or MailFile().
137
138           Keep in mind that if you use some encoding you should either use
139           SendEnc() or encode the data yourself !
140
141       charset
142           ""=> the charset of the message
143
144       client
145           ""=> the name of the client computer.
146
147           During the connection you send the mailserver your computer's name.
148           By default Mail::Sender sends "(gethostbyname 'localhost')[0]".  If
149           that is not the address you need, you can specify a different one.
150
151       priority
152           ""=> the message priority number
153
154           1 = highest, 2 = high, 3 = normal, 4 = low, 5 = lowest
155
156       confirm
157           ""=> whether you request reading or delivery confirmations and to
158           what addresses:
159
160                   "delivery" - only delivery, to the C<from> address
161                   "reading" - only reading, to the C<from> address
162                   "delivery, reading" - both confirmations, to the C<from> address
163                   "delivery: my.other@address.com" - only delivery, to my.other@address.com
164                   ...
165
166           Keep in mind though that neither of those is guaranteed to work.
167           Some servers/mail clients do not support this feature and some
168           users/admins may have disabled it. So it's possible that your mail
169           was delivered and read, but you wount get any confirmation!
170
171       ESMPT
172                   ESMTP => {
173                           NOTIFY => 'SUCCESS,FAILURE,DELAY',
174                           RET => 'HDRS',
175                           ORCPT => 'rfc822;my.other@address.com',
176                           ENVID => 'iuhsdfobwoe8t237',
177                   }
178
179           This option contains data for SMTP extensions, for example it
180           allows you to request delivery status notifications according to
181           RFC1891.
182
183           NOTIFY - to specify the conditions under which a delivery status
184           notification should be generated.  Should be either "NEVER" or a
185           comma separated list of "SUCCESS", "FAILURE"  and "DELAY".
186
187           ORCPT - used to convey the "original" (sender-specified) recipient
188           address
189
190           RET - to request that Delivery Status Notifications containing an
191           indication of delivery failure either return the entire contents of
192           a message or only the message headers. Must be either FULL or HDRS
193
194           ENVID - used to propagate an identifier for this message
195           transmission envelope, which is also known to the sender and will,
196           if present, be returned in any Delivery Status Notifications
197           issued for this transmission
198
199           You do not need to worry about encoding the ORCPT or ENVID
200           parameters.
201
202           If the SMTP server you connect to doesn't support this extension,
203           the options will be ignored.
204
205       debug
206           ""=> "/path/to/debug/file.txt"
207
208           or
209
210           ""=>  \*FILEHANDLE
211
212           or
213
214           ""=> $FH
215
216           All the conversation with the server will be logged to that file or
217           handle.  All lines in the file should end with CRLF (the Windows
218           and Internet format).  If even a single one of them does not,
219           please let me know!
220
221           If you pass the path to the log file, Mail::Sender will overwrite
222           it. If you want to append to the file, you have to open it yourself
223           and pass the filehandle:
224
225                   open my $DEBUG, ">> /path/to/debug/file.txt"
226                           or die "Can't open the debug file: $!\n"
227                   $sender = new Mail::Sender ({
228                           ...
229                           debug => $DEBUG,
230                   });
231
232       debug_level
233           Only taken into account if the "debug" option is specified.
234
235                   1 - only log the conversation with the server, skip all message data
236                   2 - log the conversation and message headers
237                   3 - log the conversation and the message and part headers
238                   4 - log everything (default)
239
240       auth
241           the SMTP authentication protocol to use to login to the server
242           currently the only ones supported are LOGIN, PLAIN, CRAM-MD5 and
243           NTLM.
244
245           Some protocols have module dependencies. CRAM-MD5 depends on
246           Digest::HMAC_MD5 and NTLM on Authen::NTLM.
247
248           You may add support for other authentication protocols yourself.
249           See below.
250
251       authid
252           the username used to login to the server
253
254       authpwd
255           the password used to login to the server
256
257       authdomain
258           the domain name. Used optionaly by the NTLM authentication.
259
260           Other authentication protocols may use other options as well.  They
261           should all start with "auth" though.
262
263           Please see the authentication section bellow.
264
265       auth_encoded
266           If set to a true value the LOGIN authentication assumes the authid
267           and authpwd is already base64 encoded.
268
269       keepconnection
270           If set to a true value causes the Mail::Sender to keep the
271           connection open for several messages.  The connection will be
272           closed if you call the Close() method with a true value or if you
273           call Open, OpenMultipart, MailMsg or MailFile with the "smtp"
274           parameter.  This means that if you want the object to keep the
275           connection you should pass the "smtp" either to "new Mail::Sender"
276           or only to the first Open, OpenMultipart, MailMsg or MailFile!
277
278       skip_bad_recipients
279           If this option is set to false or not specified then Mail::Sender
280           stops trying to send a message as soon as the first recipient's
281           address fails. If it is set to a true value Mail::Sender skips the
282           bad addresses and tries to send the message at least to the good
283           ones. If all addresses are rejected by the server it reports an
284           "All recipients were rejected" message.
285
286           If any addresses were skipped the "$sender->{'skipped_recipients'}"
287           will be a reference to a hash containing the failed address and the
288           server's response.
289
290       createmessageid
291           This option allows you to overwrite the function that generates the
292           message IDs for the emails.  The function gets the "pure" sender's
293           address as it's only parameter and is supposed to return a string.
294           See the MessageID subroutine in Mail::Sender.pm.
295
296           If you want to specify a message id you can also use the
297           "messageid" parameter for the Open, OpenMultipart, MailMsg or
298           MailFile methods.
299
300       on_errors
301           This option allows you to affect the way Mail::Sender reports
302           errors.
303
304                   => 'die' - raise an exception
305                   => 'code' - return the negative error code (default)
306                   => 'undef' - return an undef
307
308           $Mail::Sender::Error, $sender->{'error'} and $sender->{'error_msg'}
309           are set in all the cases.
310
311           All methods return the $sender object if they succeed.
312
313           P.S.: The die_on_errors option is deprecated. You may still use it,
314           but it may be removed in future versions!
315
316   Return codes
317         ref to a Mail::Sender object =  success
318
319         -1 = $smtphost unknown
320         -2 = socket() failed
321         -3 = connect() failed
322         -4 = service not available
323         -5 = unspecified communication error
324         -6 = local user $to unknown on host $smtp
325         -7 = transmission of message failed
326         -8 = argument $to empty
327         -9 = no message specified in call to MailMsg or MailFile
328         -10 = no file name specified in call to SendFile or MailFile
329         -11 = file not found
330         -12 = not available in singlepart mode
331         -13 = site specific error
332         -14 = connection not established. Did you mean MailFile instead of SendFile?
333         -15 = no SMTP server specified
334         -16 = no From: address specified
335         -17 = authentication protocol not accepted by the server
336         -18 = login not accepted
337         -19 = authentication protocol is not implemented
338
339       $Mail::Sender::Error contains a textual description of last error.
340

METHODS

342   Open
343        Open([from [, replyto [, to [, smtp [, subject [, headers]]]]]])
344        Open({[from => "somebody@somewhere.com"] , [to => "else@nowhere.com"] [...]})
345
346       Opens a new message. If some parameters are unspecified or empty, it
347       uses the parameters passed to the ""$Sender=new Mail::Sender(...)"";
348
349       See "new Mail::Sender" for info about the parameters.
350
351       The only additional parameter that may not be specified directly in the
352       "new Mail::Sender" is messageid. If you set this option then the
353       message will be sent with this Message-ID, otherwise a new Message ID
354       will be generated out of the sender's address, current date+time and a
355       random number (or by the function you specified in the
356       "createmessageid" option).
357
358       After the message is sent "$sender-<{messageid}" will contain the
359       Message-ID with which the message was sent.
360
361       Returns ref to the Mail::Sender object if successfull.
362
363   OpenMultipart
364        OpenMultipart([from [, replyto [, to [, smtp [, subject [, headers [, boundary]]]]]]])
365        OpenMultipart({[from => "somebody@somewhere.com"] , [to => "else@nowhere.com"] [...]})
366
367       Opens a multipart message. If some parameters are unspecified or empty,
368       it uses the parameters passed to the "$Sender=new Mail::Sender(...)".
369
370       See "new Mail::Sender" for info about the parameters.
371
372       Returns ref to the Mail::Sender object if successfull.
373
374   MailMsg
375        MailMsg([from [, replyto [, to [, smtp [, subject [, headers]]]]]], message)
376        MailMsg({[from => "somebody@somewhere.com"]
377                 [, to => "else@nowhere.com"] [...], msg => "Message"})
378
379       Sends a message. If a mail in $sender is opened it gets closed and a
380       new mail is created and sent. $sender is then closed.  If some
381       parameters are unspecified or empty, it uses the parameters passed to
382       the ""$Sender=new Mail::Sender(...)"";
383
384       See "new Mail::Sender" for info about the parameters.
385
386       The module was made so that you could create an object initialized with
387       all the necesary options and then send several messages without need to
388       specify the SMTP server and others each time. If you need to send only
389       one mail using MailMsg() or MailFile() you do not have to create a
390       named object and then call the method. You may do it like this :
391
392        (new Mail::Sender)->MailMsg({smtp => 'mail.company.com', ...});
393
394       Returns ref to the Mail::Sender object if successfull.
395
396   MailFile
397        MailFile([from [, replyto [, to [, smtp [, subject [, headers]]]]]], message, file(s))
398        MailFile({[from => "somebody@somewhere.com"]
399                  [, to => "else@nowhere.com"] [...],
400                  msg => "Message", file => "File"})
401
402       Sends one or more files by mail. If a mail in $sender is opened it gets
403       closed and a new mail is created and sent. $sender is then closed.  If
404       some parameters are unspecified or empty, it uses the parameters passed
405       to the ""$Sender=new Mail::Sender(...)"";
406
407       The "file" parameter may be a "filename", a "list, of, file, names" or
408       a \@list_of_file_names.
409
410       see "new Mail::Sender" for info about the parameters.
411
412       Just keep in mind that parameters like ctype, charset and encoding will
413       be used for the attached file, not the body of the message.  If you
414       want to specify those parameters for the body you have to use b_ctype,
415       b_charset and b_encoding. Sorry.
416
417       Returns ref to the Mail::Sender object if successfull.
418
419   Send
420        Send(@strings)
421
422       Prints the strings to the socket. Doesn't add any end-of-line
423       characters.  Doesn't encode the data! You should use "\r\n" as the end-
424       of-line!
425
426       UNLESS YOU ARE ABSOLUTELY SURE YOU KNOW WHAT YOU ARE DOING YOU SHOULD
427       USE SendEnc() INSTEAD!
428
429       Returns the object if successfull.
430
431   SendLine
432        SendLine(@strings)
433
434       Prints the strings to the socket. Adds the end-of-line character at the
435       end.  Doesn't encode the data! You should use "\r\n" as the end-of-
436       line!
437
438       UNLESS YOU ARE ABSOLUTELY SURE YOU KNOW WHAT YOU ARE DOING YOU SHOULD
439       USE SendLineEnc() INSTEAD!
440
441       Returns the object if successfull.
442
443   print
444       Alias to SendEnc().
445
446       Keep in mind that you can't write :
447
448               print $sender "...";
449
450       you have to use
451
452               $sender->print("...");
453
454       If you want to be able to print into the message as if it was a normal
455       file handle take a look at "GetHandle"()
456
457   SendEnc
458        SendEnc(@strings)
459
460       Prints the strings to the socket. Doesn't add any end-of-line
461       characters.
462
463       Encodes the text using the selected encoding
464       (none/Base64/Quoted-printable)
465
466       Returns the object if successfull.
467
468   SendLineEnc
469        SendLineEnc(@strings)
470
471       Prints the strings to the socket and adds the end-of-line character at
472       the end.  Encodes the text using the selected encoding
473       (none/Base64/Quoted-printable).
474
475       Do NOT mix up /Send(Line)?(Ex)?/ and /Send(Line)?Enc/! SendEnc does
476       some buffering necessary for correct Base64 encoding, and /Send(Ex)?/
477       is not aware of that!
478
479       Usage of /Send(Line)?(Ex)?/ in non xBIT parts not recommended.  Using
480       "Send(encode_base64($string))" may work, but more likely it will not!
481       In particular if you use several such to create one part, the data is
482       very likely to get crippled.
483
484       Returns the object if successfull.
485
486   SendEx
487        SendEx(@strings)
488
489       Prints the strings to the socket. Doesn't add any end-of-line
490       characters.  Changes all end-of-lines to "\r\n". Doesn't encode the
491       data!
492
493       UNLESS YOU ARE ABSOLUTELY SURE YOU KNOW WHAT YOU ARE DOING YOU SHOULD
494       USE SendEnc() INSTEAD!
495
496       Returns the object if successfull.
497
498   SendLineEx
499        SendLineEx(@strings)
500
501       Prints the strings to the socket. Adds an end-of-line character at the
502       end.  Changes all end-of-lines to "\r\n". Doesn't encode the data!
503
504       UNLESS YOU ARE ABSOLUTELY SURE YOU KNOW WHAT YOU ARE DOING YOU SHOULD
505       USE SendEnc() INSTEAD!
506
507       Returns the object if successfull.
508
509   Part
510        Part( I<description>, I<ctype>, I<encoding>, I<disposition> [, I<content_id> [, I<msg>]]);
511        Part( {[description => "desc"], [ctype => "content-type"], [encoding => "..."],
512            [disposition => "..."], [content_id => "..."], [msg => ...]});
513
514       Prints a part header for the multipart message and (if specified) the
515       contents.  The undefined or empty variables are ignored.
516
517       description
518         The title for this part.
519
520       ctype
521         the content type (MIME type) of this part. May contain some other
522         parameters, such as charset or name.
523
524         Defaults to "application/octet-stream".
525
526         Since 0.8.00 you may use even "multipart/..." types. Such a multipart
527         part should be closed by a call to $sender->EndPart($ctype).
528
529                 ...
530                 $sender->Part({ctype => "multipart/related", ...});
531                         $sender->Part({ctype => 'text/html', ...});
532                         $sender->Attach({file => 'some_image.gif', content_id => 'foo', ...});
533                 $sender->EndPart("multipart/related");
534                 ...
535
536         Please see the examples below.
537
538       encoding
539         the encoding used for this part of message. Eg. Base64, Uuencode,
540         7BIT ...
541
542         Defaults to "7BIT".
543
544       disposition
545         This parts disposition. Eg: 'attachment; filename="send.pl"'.
546
547         Defaults to "attachment". If you specify "none" or "", the Content-
548         disposition: line will not be included in the headers.
549
550       content_id
551         The content id of the part, used in multipart/related.  If not
552         specified, the header is not included.
553
554       msg
555         The content of the part. You do not have to specify the content here,
556         you may use SendEnc() to add content to the part.
557
558       charset
559         The charset of the part.
560
561       Returns the Mail::Sender object if successfull, negative error code if
562       not.
563
564   Body
565        Body([charset [, encoding [, content-type]]]);
566        Body({charset => '...', encoding => '...', ctype => '...', msg => '...');
567
568       Sends the head of the multipart message body. You can specify the
569       charset and the encoding. Default is "US-ASCII","7BIT",'text/plain'.
570
571       If you pass undef or zero as the parameter, this function uses the
572       default value:
573
574           Body(0,0,'text/html');
575
576       Returns the Mail::Sender object if successfull, negative error code if
577       not.  You should NOT use this method in single part messages, that is,
578       it works after OpenMultipart(), but has no meaning after Open()!
579
580   SendFile
581       Alias to Attach()
582
583   Attach
584        Attach( I<description>, I<ctype>, I<encoding>, I<disposition>, I<file>);
585        Attach( { [description => "desc"] , [ctype => "ctype"], [encoding => "encoding"],
586                    [disposition => "disposition"], file => "file"});
587
588        Sends a file as a separate part of the mail message. Only in multipart mode.
589
590       description
591         The title for this part.
592
593       ctype
594         the content type (MIME type) of this part. May contain some other
595         parameters, such as charset or name.
596
597         Defaults to "application/octet-stream".
598
599       encoding
600         the encoding used for this part of message. Eg. Base64, Uuencode,
601         7BIT ...
602
603         Defaults to "Base64".
604
605       disposition
606         This parts disposition. Eg: 'attachment; filename="send.pl"'. If you
607         use 'attachment; filename=*' the * will be replaced by the respective
608         names of the sent files.
609
610         Defaults to "attachment; filename=*". If you do not want to include
611         this header use "" as the value.
612
613       file
614         The name of the file to send or a 'list, of, names' or a
615         ['reference','to','a','list','of','filenames']. Each file will be
616         sent as a separate part.
617
618         Please keep in mind that if you pass a string as this parameter the
619         module will split it on commas! If your filenames may contain commas
620         and you want to be sure they are sent correctly you have to use the
621         reference to array format:
622
623                 file => [ $filename],
624
625       content_id
626         The content id of the message part. Used in multipart/related.
627
628          Special values:
629           "*" => the name of the file
630           "#" => autoincremented number (starting from 0)
631
632       Returns the Mail::Sender object if successfull, negative error code if
633       not.
634
635   EndPart
636        $sender->EndPart($ctype);
637
638       Closes a multipart part.
639
640       If the $ctype is not present or evaluates to false, only the current
641       SIMPLE part is closed!  Don't do that unless you are really sure you
642       know what you are doing.
643
644       It's best to always pass to the ->EndPart() the content type of the
645       corresponding ->Part().
646
647   Close
648        $sender->Close;
649        $sender->Close(1);
650
651       Close and send the email message. If you pass a true value to the
652       method the connection will be closed even if the "keepconnection" was
653       specified. You should only keep the connection open if you plan to send
654       another message immediately. And you should not keep it open for
655       hundreds of emails even if you do send them all in a row.
656
657       This method should be called automatically when destructing the object,
658       but you should not rely on it. If you want to be sure your message WAS
659       processed by the SMTP server you SHOULD call Close() explicitely.
660
661       Returns the Mail::Sender object if successfull, negative error code if
662       not, zero if $sender was not connected at all.  The zero usualy means
663       that the Open/OpenMultipart failed and you did not test its return
664       value.
665
666   Cancel
667        $sender->Cancel;
668
669       Cancel an opened message.
670
671       SendFile and other methods may set $sender->{'error'}.  In that case
672       "undef $sender" calls "$sender-">Cancel not "$sender-">Close!!!
673
674       Returns the Mail::Sender object if successfull, negative error code if
675       not.
676
677   QueryAuthProtocols
678               @protocols = $sender->QueryAuthProtocols();
679               @protocols = $sender->QueryAuthProtocols( $smtpserver);
680
681       Queryies the server (specified either in the default options for
682       Mail::Sender, the "new Mail::Sender" command or as a parameter to this
683       method for the authentication protocols it supports.
684
685   GetHandle
686       Returns a "filehandle" to which you can print the message or file to
687       attach or whatever.  The data you print to this handle will be encoded
688       as necessary. Closing this handle closes either the message (for single
689       part messages) or the part.
690
691               $sender->Open({...});
692               my $handle = $sender->GetHandle();
693               print $handle "Hello world.\n"
694               my ($mday,$mon,$year) = (localtime())[3,4,5];
695               printf $handle "Today is %04d/%02d/%02d.", $year+1900, $mon+1, $mday;
696               close $handle;
697
698       P.S.: There is a big difference between the handle stored in
699       $sender->{'socket'} and the handle returned by this function ! If you
700       print something to $sender->{'socket'} it will be sent to the server
701       without any modifications, encoding, escaping, ...  You should NOT
702       touch the $sender->{'socket'} unless you really really know what you
703       are doing.
704

FUNCTIONS

706   GuessCType
707               $ctype = GuessCType $filename, $filepath;
708
709       Guesses the content type based on the filename or the file contents.
710       This function is used when you attach a file and do not specify the
711       content type.  It is not exported by default!
712
713       The builtin version uses the filename extension to guess the type.
714       Currently there are only a few extensions defined, you may add other
715       extensions this way:
716
717               $Mail::Sender::CTypes{'EXT'} = 'content/type';
718               ...
719
720       The extension has to be in UPPERCASE and will be matched case
721       sensitively.
722
723       The package now includes two addins improving the guesswork. If you
724       "use" one of them in your script, it replaces the builtin GuessCType()
725       subroutine with a better one:
726
727               Mail::Sender::CType::Win32
728                       Win32 only, the content type is read from the registry
729               Mail::Sender::CType::Ext
730                       any OS, a longer list of extensions from A. Guillaume
731
732   ResetGMTdiff
733               ResetGMTdiff()
734
735       The module computes the local vs. GMT time difference to include in the
736       timestamps added into the message headers. As the time difference may
737       change due to summer savings time changes you may want to reset the
738       time difference ocassionaly in long running programs.
739

CONFIG

741       If you create a file named Sender.config in the same directory where
742       Sender.pm resides, this file will be "require"d as soon as you "use
743       Mail::Sender" in your script. Of course the Sender.config MUST "return
744       a true value", that is it has to be succesfully compiled and the last
745       statement must return a true value. You may use this to forbide the use
746       of Mail::Sender to some users.
747
748       You may define the default settings for new Mail::Sender objects and do
749       a few more things.
750
751       The default options are stored in hash %Mail::Sender::default. You may
752       use all the options you'd use in "new", "Open", "OpenMultipart",
753       "MailMsg" or "MailFile".
754
755        Eg.
756         %default = (
757           smtp => 'mail.yourhost.cz',
758           from => getlogin.'yourhost.cz',
759           client => getlogin.'.yourhost.cz'
760         );
761         # of course you will use your own mail server here !
762
763       The other options you may set here (or later of course) are
764       $Mail::Sender::SITE_HEADERS, $Mail::Sender::NO_X_MAILER and
765       $Mail::Sender::NO_DATE. (These are plain old scalar variables, there is
766       no function or method for modifying them. Just set them to anything you
767       need.)
768
769       The $Mail::Sender::SITE_HEADERS may contain headers that will be added
770       to each mail message sent by this script, the
771       $Mail::Sender::NO_X_MAILER disables the header item specifying that the
772       message was sent by Mail::Sender and $Mail::Sender::NO_DATE turns off
773       the Date: header generation.
774
775       !!! $Mail::Sender::SITE_HEADERS may NEVER end with \r\n !!!
776
777       If you want to set the $Mail::Sender::SITE_HEADERS for every script
778       sent from your server without your users being able to change it you
779       may use this hack:
780
781        $loginname = something_that_identifies_the_user();
782        *Mail::Sender::SITE_HEADERS = \"X-Sender: $loginname via $0";
783        $Mail::Sender::NO_X_MAILER = 1;
784
785       You may even "install" your custom function that will be evaluated for
786       each message just before contacting the server. You may change all the
787       options from within as well as stop sending the message.
788
789       All you have to do is to create a function named SiteHook in
790       Mail::Sender package. This function will get the Mail::Sender object as
791       its first argument. If it returns a TRUE value the message is sent, if
792       it returns FALSE the sending is canceled and the user gets "Site
793       specific error" error message.
794
795       If you want to give some better error message you may do it like this :
796
797        sub SiteHook {
798         my $self = shift;
799         if (whatever($self)) {
800           $self->Error( SITEERROR);
801           $Mail::Sender::Error = "I don't like this mail";
802           return 0
803         } else {
804           return 1;
805         }
806        }
807
808       This example will ensure the from address is the users real address :
809
810        sub SiteHook {
811         my $self = shift;
812         $self->{'fromaddr'} = getlogin.'@yoursite.com';
813         $self->{'from'} = getlogin.'@yoursite.com';
814         1;
815        }
816
817       Please note that at this stage the from address is in two different
818       object properties.
819
820       $self->{'from'} is the address as it will appear in the mail, that is
821       it may include the full name of the user or any other comment ( "Jan
822       Krynicky <jenda@krynicky.cz>" for example), while the
823       $self->{'fromaddr'} is realy just the email address per se and it will
824       be used in conversation with the SMTP server. It must be without
825       comments ("jenda@krynicky.cz" for example)!
826
827       Without write access to .../lib/Mail/Sender.pm or
828       .../lib/Mail/Sender.config your users will then be unable to get rid of
829       this header. Well ... everything is doable, if they are cheeky enough
830       ... :-(
831
832       So if you take care of some site with virtual servers for several
833       clients and implement some policy via SiteHook() or
834       $Mail::Sender::SITE_HEADERS search the clients' scripts for "SiteHook"
835       and "SITE_HEADERS" from time to time. To see who's cheating.
836

AUTHENTICATION

838       If you get a "Local user "xxx@yyy.com" unknown on host "zzz"" message
839       it usualy means that your mail server is set up to forbid mail relay.
840       That is it only accepts messages to or from a local user.  If you need
841       to be able to send a message with both the sender's and recipient's
842       address remote, you need to somehow authenticate to the server. You may
843       need the help of the mail server's administrator to find out what
844       username and password and/or what authentication protocol are you
845       supposed to use.
846
847       There are many authentication protocols defined for ESTMP, Mail::Sender
848       natively supports only PLAIN, LOGIN, CRAM-MD5 and NTLM (please see the
849       docs for "new Mail::Sender").
850
851       If you want to know what protocols are supported by your server you may
852       get the list by this:
853
854               /tmp# perl -MMail::Sender -e 'Mail::Sender->printAuthProtocols("the.server.com")'
855         or
856               c:\> perl -MMail::Sender -e "Mail::Sender->printAuthProtocols('the.server.com')"
857
858       There is one more way to authenticate. Some servers want you to login
859       by POP3 before you can send a message. You have to use Net::POP3 or
860       Mail::POP3Client to do this.
861
862   Other protocols
863       It is possible to add new authentication protocols to Mail::Sender. All
864       you have to do is to define a function
865       Mail::Sender::Auth::PROTOCOL_NAME that will implement the login. The
866       function gets one parameter ... the Mail::Sender object.  It can access
867       these properties:
868
869               $obj->{'socket'} : the socket to print to and read from
870                       you may use the send_cmd() function to send a request
871                       and read a response from the server
872               $obj->{'authid'} : the username specified in the new Mail::Sender,
873                       Open or OpenMultipart call
874               $obj->{'authpwd'} : the password
875               $obj->{auth...} : all unknown parameters passed to the constructor or the mail
876                       opening/creation methods are preserved in the object. If the protocol requires
877                       any other options, please use names starting with "auth". Eg. "authdomain", ...
878               $obj->{'error'} : this should be set to a negative error number. Please use numbers
879                       below -1000 for custom errors.
880               $obj->{'error_msg'} : this should be set to the error message
881
882               If the login fails you should
883                       1) Set $Mail::Sender::Error to the error message
884                       2) Set $obj->{'error_msg'} to the error message
885                       2) Set $obj->{'error'} to a negative number
886                       3) return a negative number
887               If it succeeds, please return "nothing" :
888                       return;
889
890       Please use the protocols defined within Sender.pm as examples.
891

EXAMPLES

893   Object creation
894        ref ($sender = new Mail::Sender { from => 'somebody@somewhere.com',
895              smtp => 'mail.yourISP.com', boundary => 'This-is-a-mail-boundary-435427'})
896        or die "Error in mailing : $Mail::Sender::Error\n";
897
898       or
899
900        my $sender = new Mail::Sender { ... };
901        die "Error in mailing : $Mail::Sender::Error\n" unless ref $sender;
902
903       or
904
905        my $sender = new Mail::Sender { ..., on_errors => 'undef' }
906          or die "Error in mailing : $Mail::Sender::Error\n";
907
908       You may specify the options either when creating the Mail::Sender
909       object or later when you open a message. You may also set the default
910       options when installing the module (See "CONFIG" section). This way the
911       admin may set the SMTP server and even the authentication options and
912       the users do not have to specify it again.
913
914       You should keep in mind that the way Mail::Sender reports failures
915       depends on the 'on_errors'=> option. If you set it to 'die' it throws
916       an exception, if you set it to "undef" or 'undef' it returns undef and
917       otherwise it returns a negative error code!
918
919   Simple single part message
920               $sender = new Mail::Sender {
921                       smtp => 'mail.yourISP.com',
922                       from => 'somebody@somewhere.com',
923                       on_errors => undef,
924               }
925                       or die "Can't create the Mail::Sender object: $Mail::Sender::Error\n";
926               $sender->Open({
927                       to => 'mama@home.org, papa@work.com',
928                       cc => 'somebody@somewhere.com',
929                       subject => 'Sorry, I\'ll come later.'
930               })
931                       or die "Can't open the message: $sender->{'error_msg'}\n";
932               $sender->SendLineEnc("I'm sorry, but thanks to the lusers,
933                       I'll come at 10pm at best.");
934               $sender->SendLineEnc("\nHi, Jenda");
935               $sender->Close()
936                       or die "Failed to send the message: $sender->{'error_msg'}\n";
937
938       or
939
940               eval {
941                       $sender = new Mail::Sender {
942                               smtp => 'mail.yourISP.com',
943                               from => 'somebody@somewhere.com',
944                               on_errors => 'die',
945                       };
946                       $sender->Open({
947                               to => 'mama@home.org, papa@work.com',
948                               cc => 'somebody@somewhere.com',
949                               subject => 'Sorry, I\'ll come later.'
950                       });
951                       $sender->SendLineEnc("I'm sorry, but thanks to the lusers,
952                               I'll come at 10pm at best.");
953                       $sender->SendLineEnc("\nHi, Jenda");
954                       $sender->Close();
955               };
956               if ($@) {
957                       die "Failed to send the message: $@\n";
958               }
959
960       or
961
962               $sender = new Mail::Sender {
963                       smtp => 'mail.yourISP.com',
964                       from => 'somebody@somewhere.com',
965                       on_errors => 'code',
966               };
967               die "Can't create the Mail::Sender object: $Mail::Sender::Error\n"
968                       unless ref $sender;
969               ref $sender->Open({
970                       to => 'mama@home.org, papa@work.com',
971                       cc => 'somebody@somewhere.com',
972                       subject => 'Sorry, I\'ll come later.'
973               })
974                       or die "Can't open the message: $sender->{'error_msg'}\n";
975               $sender->SendLineEnc("I'm sorry, but thanks to the lusers,
976                       I'll come at 10pm at best.");
977               $sender->SendLineEnc("\nHi, Jenda");
978               ref $sender->Close
979                       or die "Failed to send the message: $sender->{'error_msg'}\n";
980
981   Using GetHandle()
982         ref $sender->Open({to => 'friend@other.com', subject => 'Hello dear friend'})
983                or die "Error: $Mail::Sender::Error\n";
984         my $FH = $sender->GetHandle();
985         print $FH "How are you?\n\n";
986         print $FH <<'*END*';
987         I've found these jokes.
988
989          Doctor, I feel like a pack of cards.
990          Sit down and I'll deal with you later.
991
992          Doctor, I keep thinking I'm a dustbin.
993          Don't talk rubbish.
994
995         Hope you like'em. Jenda
996         *END*
997
998         $sender->Close;
999         # or
1000         # close $FH;
1001
1002       or
1003
1004         eval {
1005           $sender->Open({ on_errors => 'die',
1006                                to => 'mama@home.org, papa@work.com',
1007                       cc => 'somebody@somewhere.com',
1008                       subject => 'Sorry, I\'ll come later.'});
1009           $sender->SendLineEnc("I'm sorry, but due to a big load of work,
1010         I'll come at 10pm at best.");
1011           $sender->SendLineEnc("\nHi, Jenda");
1012           $sender->Close;
1013         };
1014         if ($@) {
1015           print "Error sending the email: $@\n";
1016         } else {
1017           print "The mail was sent.\n";
1018         }
1019
1020   Multipart message with attachment
1021        $sender->OpenMultipart({to => 'Perl-Win32-Users@activeware.foo',
1022                                subject => 'Mail::Sender.pm - new module'});
1023        $sender->Body;
1024        $sender->SendEnc(<<'*END*');
1025        Here is a new module Mail::Sender.
1026        It provides an object based interface to sending SMTP mails.
1027        It uses a direct socket connection, so it doesn't need any
1028        additional program.
1029
1030        Enjoy, Jenda
1031        *END*
1032        $sender->Attach(
1033         {description => 'Perl module Mail::Sender.pm',
1034          ctype => 'application/x-zip-encoded',
1035          encoding => 'Base64',
1036          disposition => 'attachment; filename="Sender.zip"; type="ZIP archive"',
1037          file => 'sender.zip'
1038         });
1039        $sender->Close;
1040
1041       or
1042
1043        $sender->OpenMultipart({to => 'Perl-Win32-Users@activeware.foo',
1044                                subject => 'Mail::Sender.pm - new version'});
1045        $sender->Body({ msg => <<'*END*' });
1046        Here is a new module Mail::Sender.
1047        It provides an object based interface to sending SMTP mails.
1048        It uses a direct socket connection, so it doesn't need any
1049        additional program.
1050
1051        Enjoy, Jenda
1052        *END*
1053        $sender->Attach(
1054         {description => 'Perl module Mail::Sender.pm',
1055          ctype => 'application/x-zip-encoded',
1056          encoding => 'Base64',
1057          disposition => 'attachment; filename="Sender.zip"; type="ZIP archive"',
1058          file => 'sender.zip'
1059         });
1060        $sender->Close;
1061
1062       or (in case you have the file contents in a scalar)
1063
1064        $sender->OpenMultipart({to => 'Perl-Win32-Users@activeware.foo',
1065                                subject => 'Mail::Sender.pm - new version'});
1066        $sender->Body({ msg => <<'*END*' });
1067        Here is a new module Mail::Sender.
1068        It provides an object based interface to sending SMTP mails.
1069        It uses a direct socket connection, so it doesn't need any
1070        additional program.
1071
1072        Enjoy, Jenda
1073        *END*
1074        $sender->Part(
1075         {description => 'Perl module Mail::Sender.pm',
1076          ctype => 'application/x-zip-encoded',
1077          encoding => 'Base64',
1078          disposition => 'attachment; filename="Sender.zip"; type="ZIP archive"',
1079          msg => $sender_zip_contents,
1080         });
1081        $sender->Close;
1082
1083   Using exceptions (no need to test return values after each function)
1084        use Mail::Sender;
1085        eval {
1086        (new Mail::Sender {on_errors => 'die'})
1087               ->OpenMultipart({smtp=> 'jenda.krynicky.cz', to => 'jenda@krynicky.cz',subject => 'Mail::Sender.pm - new version'})
1088               ->Body({ msg => <<'*END*' })
1089        Here is a new module Mail::Sender.
1090        It provides an object based interface to sending SMTP mails.
1091        It uses a direct socket connection, so it doesn't need any
1092        additional program.
1093
1094        Enjoy, Jenda
1095        *END*
1096               ->Attach({
1097                       description => 'Perl module Mail::Sender.pm',
1098                       ctype => 'application/x-zip-encoded',
1099                       encoding => 'Base64',
1100                       disposition => 'attachment; filename="Sender.zip"; type="ZIP archive"',
1101                       file => 'W:\jenda\packages\Mail\Sender\Mail-Sender-0.7.14.3.tar.gz'
1102               })
1103               ->Close();
1104        } or print "Error sending mail: $@\n";
1105
1106   Using MailMsg() shortcut to send simple messages
1107       If everything you need is to send a simple message you may use:
1108
1109        if (ref ($sender->MailMsg({to =>'Jenda@Krynicky.czX', subject => 'this is a test',
1110                                msg => "Hi Johnie.\nHow are you?"}))) {
1111         print "Mail sent OK."
1112        } else {
1113         die "$Mail::Sender::Error\n";
1114        }
1115
1116       or
1117
1118        if ($sender->MailMsg({
1119          smtp => 'mail.yourISP.com',
1120          from => 'somebody@somewhere.com',
1121          to =>'Jenda@Krynicky.czX',
1122          subject => 'this is a test',
1123          msg => "Hi Johnie.\nHow are you?"
1124        }) < 0) {
1125         die "$Mail::Sender::Error\n";
1126        }
1127        print "Mail sent OK."
1128
1129   Using MailMsg and authentication
1130        if ($sender->MailMsg({
1131          smtp => 'mail.yourISP.com',
1132          from => 'somebody@somewhere.com',
1133          to =>'Jenda@Krynicky.czX',
1134          subject => 'this is a test',
1135          msg => "Hi Johnie.\nHow are you?"
1136          auth => 'NTLM',
1137          authid => 'jenda',
1138          authpwd => 'benda',
1139        }) < 0) {
1140         die "$Mail::Sender::Error\n";
1141        }
1142        print "Mail sent OK."
1143
1144   Using MailFile() shortcut to send an attachment
1145       If you want to attach some files:
1146
1147        (ref ($sender->MailFile(
1148         {to =>'you@address.com', subject => 'this is a test',
1149          msg => "Hi Johnie.\nI'm sending you the pictures you wanted.",
1150          file => 'image1.jpg,image2.jpg'
1151         }))
1152         and print "Mail sent OK."
1153        )
1154        or die "$Mail::Sender::Error\n";
1155
1156   Sending HTML messages
1157       If you are sure the HTML doesn't contain any accentuated characters
1158       (with codes above 127).
1159
1160        open IN, $htmlfile or die "Cannot open $htmlfile : $!\n";
1161        $sender->Open({ from => 'your@address.com', to => 'other@address.com',
1162               subject => 'HTML test',
1163               ctype => "text/html",
1164               encoding => "7bit"
1165        }) or die $Mail::Sender::Error,"\n";
1166
1167        while (<IN>) { $sender->SendEx($_) };
1168        close IN;
1169        $sender->Close();
1170
1171       Otherwise use SendEnc() instead of SendEx() and "quoted-printable"
1172       instead of "7bit".
1173
1174       Another ... quicker way ... would be:
1175
1176        open IN, $htmlfile or die "Cannot open $htmlfile : $!\n";
1177        $sender->Open({ from => 'your@address.com', to => 'other@address.com',
1178               subject => 'HTML test',
1179               ctype => "text/html",
1180               encoding => "quoted-printable"
1181        }) or die $Mail::Sender::Error,"\n";
1182
1183        while (read IN, $buff, 4096) { $sender->SendEnc($buff) };
1184        close IN;
1185        $sender->Close();
1186
1187   Sending HTML messages with inline images
1188               if (ref $sender->OpenMultipart({
1189                       from => 'someone@somewhere.net', to => $recipients,
1190                       subject => 'Embedded Image Test',
1191                       boundary => 'boundary-test-1',
1192                       multipart => 'related'})) {
1193                       $sender->Attach(
1194                                {description => 'html body',
1195                                ctype => 'text/html; charset=us-ascii',
1196                                encoding => '7bit',
1197                                disposition => 'NONE',
1198                                file => 'test.html'
1199                       });
1200                       $sender->Attach({
1201                               description => 'ed\'s gif',
1202                               ctype => 'image/gif',
1203                               encoding => 'base64',
1204                               disposition => "inline; filename=\"apache_pb.gif\";\r\nContent-ID: <img1>",
1205                               file => 'apache_pb.gif'
1206                       });
1207                       $sender->Close() or die "Close failed! $Mail::Sender::Error\n";
1208               } else {
1209                       die "Cannot send mail: $Mail::Sender::Error\n";
1210               }
1211
1212       And in the HTML you'll have this :
1213        ... <IMG src="cid:img1"> ...  on the place where you want the inlined
1214       image.
1215
1216       Please keep in mind that the image name is unimportant, it's the
1217       Content-ID what counts!
1218
1219       # or using the eval{ $obj->Method()->Method()->...->Close()} trick ...
1220
1221               use Mail::Sender;
1222               eval {
1223               (new Mail::Sender)
1224                       ->OpenMultipart({
1225                               to => 'someone@somewhere.com',
1226                               subject => 'Embedded Image Test',
1227                               boundary => 'boundary-test-1',
1228                               type => 'multipart/related'
1229                       })
1230                       ->Attach({
1231                               description => 'html body',
1232                               ctype => 'text/html; charset=us-ascii',
1233                               encoding => '7bit',
1234                               disposition => 'NONE',
1235                               file => 'c:\temp\zk\HTMLTest.htm'
1236                       })
1237                       ->Attach({
1238                               description => 'Test gif',
1239                               ctype => 'image/gif',
1240                               encoding => 'base64',
1241                               disposition => "inline; filename=\"test.gif\";\r\nContent-ID: <img1>",
1242                               file => 'test.gif'
1243                       })
1244                       ->Close()
1245               }
1246               or die "Cannot send mail: $Mail::Sender::Error\n";
1247
1248   Sending message with plaintext and HTML alternatives
1249               use Mail::Sender;
1250
1251               eval {
1252                       (new Mail::Sender)
1253                       ->OpenMultipart({
1254                               to => 'someone@somewhere.com',
1255                               subject => 'Alternatives',
1256               #               debug => 'c:\temp\zkMailFlow.log',
1257                               multipart => 'mixed',
1258                       })
1259                               ->Part({ctype => 'multipart/alternative'})
1260                                       ->Part({ ctype => 'text/plain', disposition => 'NONE', msg => <<'*END*' })
1261               A long
1262               mail
1263               message.
1264               *END*
1265                                       ->Part({ctype => 'text/html', disposition => 'NONE', msg => <<'*END*'})
1266               <html><body><h1>A long</h1><p align=center>
1267               mail
1268               message.
1269               </p></body></html>
1270               *END*
1271                               ->EndPart("multipart/alternative")
1272                       ->Close();
1273               } or print "Error sending mail: $Mail::Sender::Error\n";
1274
1275   Sending message with plaintext and HTML alternatives with inline images
1276               use Mail::Sender;
1277
1278               eval {
1279                       (new Mail::Sender)
1280                       ->OpenMultipart({
1281                               to => 'someone@somewhere.com',
1282                               subject => 'Alternatives with images',
1283               #               debug => 'c:\temp\zkMailFlow.log',
1284                               multipart => 'related',
1285                       })
1286                               ->Part({ctype => 'multipart/alternative'})
1287                                       ->Part({ ctype => 'text/plain', disposition => 'NONE', msg => <<'*END*' })
1288               A long
1289               mail
1290               message.
1291               *END*
1292                                       ->Part({ctype => 'text/html', disposition => 'NONE', msg => <<'*END*'})
1293               <html><body><h1>A long</h1><p align=center>
1294               mail
1295               message.
1296               <img src="cid:img1">
1297               </p></body></html>
1298               *END*
1299                               ->EndPart("multipart/alternative")
1300                               ->Attach({
1301                                       description => 'ed\'s jpg',
1302                                       ctype => 'image/jpeg',
1303                                       encoding => 'base64',
1304                                       disposition => "inline; filename=\"0518m_b.jpg\";\r\nContent-ID: <img1>",
1305                                       file => 'E:\pix\humor\0518m_b.jpg'
1306                               })
1307                       ->Close();
1308               } or print "Error sending mail: $Mail::Sender::Error\n";
1309
1310       Keep in mind please that different mail clients display messages
1311       differently. You may need to try several ways to create messages so
1312       that they appear the way you need.  These two examples looked like I
1313       expected in Pegasus Email and MS Outlook.
1314
1315       If this doesn't work with your mail client, please let me know and we
1316       might find a way.
1317
1318   Sending a file that was just uploaded from an HTML form
1319        use CGI;
1320        use Mail::Sender;
1321
1322        $query = new CGI;
1323
1324        # uploading the file...
1325        $filename = $query->param('mailformFile');
1326        if ($filename ne ""){
1327         $tmp_file = $query->tmpFileName($filename);
1328        }
1329
1330        $sender = new Mail::Sender {from => 'script@krynicky.cz',smtp => 'mail.krynicky.czX'};
1331        $sender->OpenMultipart({to=> 'jenda@krynicky.czX',subject=> 'test CGI attach'});
1332        $sender->Body();
1333        $sender->Send(<<"*END*");
1334        This is just a test of mail with an uploaded file.
1335
1336        Jenda
1337        *END*
1338        $sender->Attach({
1339           encoding => 'Base64',
1340           description => $filename,
1341           ctype => $query->uploadInfo($filename)->{'Content-Type'},
1342           disposition => "attachment; filename = $filename",
1343           file => $tmp_file
1344        });
1345        $sender->Close();
1346
1347        print "Content-type: text/plain\n\nYes, it's sent\n\n";
1348
1349   Listing the authentication protocols supported by the server
1350        use Mail::Sender;
1351        my $sender = new Mail::Sender {smtp => 'localhost'};
1352        die "Error: $Mail::Sender::Error\n" unless ref $sender;
1353        print join(', ', $sender->QueryAuthProtocols()),"\n";
1354
1355       or (if you have Mail::Sender 0.8.05 or newer)
1356
1357        use Mail::Sender;
1358        print join(', ', Mail::Sender->QueryAuthProtocols('localhost')),"\n";
1359
1360       or
1361
1362        use Mail::Sender;
1363        print join(', ', Mail::Sender::QueryAuthProtocols('localhost')),"\n";
1364
1365   FAQ
1366       Forwarding the messages created by Mail::Sender removes accents. Why?
1367
1368       The most likely colprit is missing or incorrect charset specified for
1369       the body or a part of the email. You should add something like
1370
1371               charset => 'iso-8859-1',
1372               encoding => 'quoted-printable',
1373
1374       to the parameters passed to Open(), OpenMultipart(), MailMsg(), Body()
1375       or Part() or
1376
1377               b_charset => 'iso-8859-1',
1378               b_encoding => 'quoted-printable',
1379
1380       to the parameters for MailFile().
1381
1382       If you use a different charset ('iso-8859-2', 'win-1250', ...) you will
1383       of course need to specify that charset. If you are not sure, try to
1384       send a mail with some other mail client and then look at the
1385       message/part headers.
1386
1387   Sometimes there is an equals sign at the end of an attached file when I
1388       open the email in Outlook. What's wrong?
1389       Outlook is. It has (had) a bug in its quoted printable decoding
1390       routines.  This problem happens only in quoted-printable encoded parts
1391       on multipart messages.  And only if the data in that part do not end
1392       with a newline. (This is new in 0.8.08, in older versions it happened
1393       in all QP encoded parts.)
1394
1395       The problem is that an equals sign at the end of a line in a quoted
1396       printable encoded text means "ignore the newline". That is
1397
1398               fooo sdfg sdfg sdfh dfh =
1399               dfsgdsfg
1400
1401       should be decoded as
1402
1403               fooo sdfg sdfg sdfh dfh dfsgdsfg
1404
1405       The problem is at the very end of a file. The part boundary (text
1406       separating different parts of a multipart message) has to start on a
1407       new line, if the attached file ends by a newline everything is cool.
1408       If it doesn't I need to add a newline and to denote that the newline is
1409       not part of the original file I add an equals:
1410
1411               dfgd dsfgh dfh dfh dfhdfhdfhdfgh
1412               this is the last line.=
1413               --message-boundary-146464--
1414
1415       Otherwise I'd add a newline at the end of the file.  If you do not care
1416       about the newline and want to be sure Outlook doesn't add the equals to
1417       the file add
1418
1419               bypass_outlook_bug => 1
1420
1421       parameter to "new Mail::Sender" or "Open"/"OpenMultipart".
1422
1423   WARNING
1424       DO NOT mix Open(Multipart)|Send(Line)(Ex)|Close with MailMsg or
1425       MailFile.  Both Mail(Msg/File) close any Open-ed mail.  Do not try
1426       this:
1427
1428        $sender = new Mail::Sender ...;
1429        $sender->OpenMultipart...;
1430        $sender->Body;
1431        $sender->Send("...");
1432        $sender->MailFile({file => 'something.ext');
1433        $sender->Close;
1434
1435       This WON'T work!!!
1436
1437   GOTCHAS
1438       Local user "someone@somewhere.com" doesn't exist
1439
1440       "Thanks" to spammers mail servers usualy do not allow just anyone to
1441       post a message through them.  Most often they require that either the
1442       sender or the recipient is local to the server
1443
1444       Mail::Sendmail works, Mail::Sender doesn't
1445
1446       If you are able to connect to the mail server and scripts using
1447       Mail::Sendmail work, but Mail::Sender fails with "connect() failed",
1448       please review the settings in /etc/services. The port for SMTP should
1449       be 25.
1450
1451       $/ and $\
1452
1453       If you change the $/ ($RS, $INPUT_RECORD_SEPARATOR) or $\ ($ORS,
1454       $OUTPUT_RECORD_SEPARATOR) or $, ($OFS, $OUTPUT_FIELD_SEPARATOR)
1455       Mail::Sender may stop working! Keep in mind that those variables are
1456       global and therefore they change the behaviour of <> and print
1457       everywhere.  And since the SMTP is a plain text protocol if you change
1458       the notion of lines you can break it.
1459
1460       If you have to fiddle with $/, $\ or $, do it in the smallest possible
1461       block of code and local()ize the change!
1462
1463               open my $IN, '<', $filename or die "Can't open $filename: $!\n";
1464               my $data = do {local $/; <$IN>};
1465               close $IN;
1466

BUGS

1468       I'm sure there are many. Please let me know if you find any.
1469
1470       The problem with multiline responses from some SMTP servers (namely
1471       qmail) is solved. At last.
1472

SEE ALSO

1474       MIME::Lite, MIME::Entity, Mail::Sendmail, Mail::Mailer, ...
1475
1476       There are lots of mail related modules on CPAN, with different
1477       capabilities and interfaces. You have to find the right one yourself
1478       :-)
1479

DISCLAIMER

1481       This module is based on SendMail.pm Version : 1.21 that appeared in
1482       Perl-Win32-Users@activeware.com mailing list. I don't remember the name
1483       of the poster and it's not mentioned in the script. Thank you mr.
1484       "undef".
1485

AUTHOR

1487       Jan Krynicky <Jenda@Krynicky.cz> http://Jenda.Krynicky.cz
1488
1489       With help of Rodrigo Siqueira <rodrigo@insite.com.br>, Ed McGuigan
1490       <itstech1@gate.net>, John Sanche <john@quadrant.net>, Brian Blakley
1491       <bblakley@mp5.net>, and others.
1492
1494       Copyright (c) 1997-2006 Jan Krynicky <Jenda@Krynicky.cz>. All rights
1495       reserved.
1496
1497       This program is free software; you can redistribute it and/or modify it
1498       under the same terms as Perl itself. There is only one aditional
1499       condition, you may NOT use this module for SPAMing! NEVER! (see
1500       http://spam.abuse.net/ for definition)
1501
1502
1503
1504perl v5.12.0                      2008-07-14                         Sender(3)
Impressum