Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

122 lines
3.6 KiB

  1. # ======================================================================
  2. #
  3. # Copyright (C) 2000-2001 Paul Kulchenko ([email protected])
  4. # SOAP::Lite is free software; you can redistribute it
  5. # and/or modify it under the same terms as Perl itself.
  6. #
  7. # $Id: SOAP::Transport::MAILTO.pm,v 0.51 2001/07/18 15:15:14 $
  8. #
  9. # ======================================================================
  10. package SOAP::Transport::MAILTO;
  11. use strict;
  12. use vars qw($VERSION);
  13. $VERSION = '0.51';
  14. use MIME::Lite;
  15. use URI;
  16. # ======================================================================
  17. package SOAP::Transport::MAILTO::Client;
  18. use vars qw(@ISA);
  19. @ISA = qw(SOAP::Client);
  20. sub DESTROY { SOAP::Trace::objects('()') }
  21. sub new {
  22. my $self = shift;
  23. unless (ref $self) {
  24. my $class = ref($self) || $self;
  25. my(@params, @methods);
  26. while (@_) { $class->can($_[0]) ? push(@methods, shift() => shift) : push(@params, shift) }
  27. $self = bless {@params} => $class;
  28. while (@methods) { my($method, $params) = splice(@methods,0,2);
  29. $self->$method(ref $params eq 'ARRAY' ? @$params : $params)
  30. }
  31. SOAP::Trace::objects('()');
  32. }
  33. return $self;
  34. }
  35. sub send_receive {
  36. my($self, %parameters) = @_;
  37. my($envelope, $endpoint, $action) =
  38. @parameters{qw(envelope endpoint action)};
  39. $endpoint ||= $self->endpoint;
  40. my $uri = URI->new($endpoint);
  41. %parameters = (%$self, map {URI::Escape::uri_unescape($_)} map {split/=/,$_,2} split /[&;]/, $uri->query || '');
  42. my $msg = MIME::Lite->new(
  43. To => $uri->to,
  44. Type => 'text/xml',
  45. Encoding => $parameters{Encoding} || 'base64',
  46. Data => $envelope,
  47. $parameters{From} ? (From => $parameters{From}) : (),
  48. $parameters{'Reply-To'} ? ('Reply-To' => $parameters{'Reply-To'}) : (),
  49. $parameters{Subject} ? (Subject => $parameters{Subject}) : (),
  50. );
  51. $msg->replace('X-Mailer' => join '/', 'SOAP::Lite', 'Perl', SOAP::Transport::MAILTO->VERSION);
  52. $msg->add(SOAPAction => $action);
  53. SOAP::Trace::transport($msg);
  54. SOAP::Trace::debug($msg->as_string);
  55. MIME::Lite->send(map {exists $parameters{$_} ? ($_ => $parameters{$_}) : ()} 'smtp', 'sendmail');
  56. eval { local $SIG{__DIE__}; $MIME::Lite::AUTO_CC = 0; $msg->send };
  57. (my $code = $@) =~ s/ at .*\n//;
  58. $self->code($code);
  59. $self->message($code);
  60. $self->is_success(!defined $code || $code eq '');
  61. $self->status($code);
  62. return;
  63. }
  64. # ======================================================================
  65. 1;
  66. =head1 NAME
  67. SOAP::Transport::MAILTO - Client side SMTP/sendmail support for SOAP::Lite
  68. =head1 SYNOPSIS
  69. use SOAP::Lite;
  70. SOAP::Lite
  71. -> uri('http://soaplite.com/My/Examples')
  72. -> proxy('mailto:destination.email@address', smtp => 'smtp.server', From => 'your.email', Subject => 'SOAP message')
  73. # or
  74. # -> proxy('mailto:destination.email@address?From=your.email&Subject=SOAP%20message', smtp => 'smtp.server')
  75. # or if you want to send with sendmail
  76. # -> proxy('mailto:destination.email@address?From=your.email&Subject=SOAP%20message')
  77. # or if your sendmail is in undiscoverable place
  78. # -> proxy('mailto:destination.email@address?From=your.email&Subject=SOAP%20message', sendmail => 'command to run your sendmail')
  79. -> getStateName(12)
  80. ;
  81. =head1 DESCRIPTION
  82. =head1 COPYRIGHT
  83. Copyright (C) 2000-2001 Paul Kulchenko. All rights reserved.
  84. This library is free software; you can redistribute it and/or modify
  85. it under the same terms as Perl itself.
  86. =head1 AUTHOR
  87. Paul Kulchenko (paulclinger@yahoo.com)
  88. =cut