PageRenderTime 54ms CodeModel.GetById 30ms RepoModel.GetById 0ms app.codeStats 0ms

/swatch-3.2.3/examples/SendMail.pm

#
Perl | 66 lines | 43 code | 20 blank | 3 comment | 0 complexity | fbb8291c64f87dc20e70dc515cd864c5 MD5 | raw file
Possible License(s): GPL-2.0
  1. package Swatch::SendMail;
  2. require 5.000;
  3. require Exporter;
  4. use strict;
  5. use Carp;
  6. use Mail::Sendmail;
  7. use Sys::Hostname;
  8. use vars qw($VERSION @ISA @EXPORT @EXPORT_OK);
  9. @ISA = qw(Exporter);
  10. @EXPORT = qw/
  11. &send_mail
  12. /;
  13. $VERSION = '20031118';
  14. ################################################################
  15. sub send_mail {
  16. my $login = (getpwuid($<))[0];
  17. my $host = hostname;
  18. my %opts = (
  19. 'ADDRESSES' => $login,
  20. 'FROM' => "$login\@$host",
  21. 'SUBJECT' => 'Message from Swatch',
  22. @_
  23. );
  24. (my $to_line = $opts{'ADDRESSES'}) =~ s/:/,/g;
  25. my %mail = ( To => $to_line,
  26. From => $opts{FROM},,
  27. Subject => $opts{SUBJECT},
  28. Message => $opts{MESSAGE},
  29. );
  30. sendmail(%mail) or warn $Mail::Sendmail::error;
  31. return 0;
  32. }
  33. ################################################################
  34. ## The POD ###
  35. =head1 NAME
  36. Swatch::SendMail - Swatch interface to the Mail::Sendmail module
  37. =head1 SYNOPSIS
  38. use Swatch::SendMail;
  39. =head1 SWATCH SYNTAX
  40. =head1 DESCRIPTION
  41. =head1 AUTHOR
  42. E. Todd Atkins, todd.atkins@stanfordalumni.org
  43. =head1 SEE ALSO
  44. perl(1), swatch(1).
  45. =cut
  46. 1;