]> pere.pagekite.me Git - homepage.git/blob - linux/wreq/no-sendmail.diff
Switched blog to hungry.com for now. Updated all links.
[homepage.git] / linux / wreq / no-sendmail.diff
1 Index: req-config
2 ===================================================================
3 RCS file: /cvsroot/its/sw/wreq/req-config,v
4 retrieving revision 1.3
5 retrieving revision 1.4
6 diff -u -w -u -r1.3 -r1.4
7 --- req-config 1999/05/15 10:20:04 1.3
8 +++ req-config 1999/05/15 10:41:24 1.4
9 @@ -11,6 +11,9 @@
10 #### How to call sendmail on your system
11 $sendmail="/usr/lib/sendmail -oi"; # will -db make the page faster to return?
12
13 +#### If $sendmail is '', relay mails thru this host
14 +$mailhost='mailhost';
15 +
16 #### The From address for errors in processing email requests
17 #### Note: to prevent mail looping, this address doesn't actually exist.
18 $error_from="Support Online Error <req-error\@localhost>";
19 Index: req-common
20 ===================================================================
21 RCS file: /cvsroot/its/sw/wreq/req-common,v
22 retrieving revision 1.1
23 retrieving revision 1.2
24 diff -u -w -u -r1.1 -r1.2
25 --- req-common 1999/05/09 21:51:08 1.1
26 +++ req-common 1999/05/15 10:41:24 1.2
27 @@ -445,8 +445,8 @@
28 sub sendMail {# . 0from 1reply-to 2tos 3ccs 4subject 5message
29 if(!$_[2]){return;} # no one to send to
30
31 - my $header=''; my $fflag=''; my $to='';
32 - if($_[0]){$header.="From: $_[0]\n";}
33 + my $header=''; my $fflag=''; my $to=''; my $from='';
34 + if($_[0]){$header.="From: $_[0]\n"; $from ="$_[0]";}
35 if($_[2]){$header.="To: $_[2]\n"; $to="$_[2]";}
36 if($_[4]){$header.="Subject: $_[4]\n";}
37 if($_[3]){$header.="Cc: $_[3]\n"; $to.=",$_[3]";}
38 @@ -455,6 +455,7 @@
39 $header.="\n$_[5]\n"; # the body
40
41 eval {
42 + if ($sendmail) {
43 # note from/tos can be of the form: aa bb <a@b>
44 open(POUT,"|$sendmail $fflag \"$to\">/dev/null 2>&1") || &html_error("cannot run sendmail: $!");
45 # redirect above so it won't mess up the http header, eval{} works too.
46 @@ -465,6 +466,23 @@
47 ### -n option should not be used, since we are sending to aliases.
48 print POUT "$header";
49 close (POUT);
50 + } else {
51 + eval 'use Net::SMTP;';
52 + $smtp = Net::SMTP->new($mailhost,
53 + Timeout => 30); # seconds
54 + if ($smtp) {
55 + $smtp->mail($from);
56 + for $user (split(/,/, $to)) {
57 + $smtp->to($user);
58 + }
59 + $smtp->data();
60 + $smtp->datasend($header);
61 + $smtp->dataend();
62 + $smtp->quit;
63 + } else {
64 + &html_error("sendMail: SMTP connect to $mailhost failed");
65 + }
66 + }
67 };
68 &html_error("sendMail: $@") if $@;
69 }
70 Index: req-mail
71 ===================================================================
72 RCS file: /cvsroot/its/sw/wreq/req-mail,v
73 retrieving revision 1.3
74 retrieving revision 1.4
75 diff -u -w -u -r1.3 -r1.4
76 --- req-mail 1999/05/15 10:22:44 1.3
77 +++ req-mail 1999/05/15 10:41:24 1.4
78 @@ -264,8 +264,8 @@
79 sub sendMail {# . 0from 1reply-to 2tos 3ccs 4subject 5message
80 if(!$_[2]){return;} # no one to send to
81
82 - my $header=''; my $fflag=''; my $to='';
83 - if($_[0]){$header.="From: $_[0]\n";}
84 + my $header=''; my $fflag=''; my $to=''; my $from='';
85 + if($_[0]){$header.="From: $_[0]\n"; $from ="$_[0]";}
86 if($_[2]){$header.="To: $_[2]\n"; $to="$_[2]";}
87 if($_[4]){$header.="Subject: $_[4]\n";}
88 if($_[3]){$header.="Cc: $_[3]\n"; $to.=",$_[3]";}
89 @@ -274,6 +274,7 @@
90 $header.="\n$_[5]\n"; # the body
91
92 eval {
93 + if ($sendmail) {
94 # note from/tos can be of the form: aa bb <a@b>
95 open(POUT,"|$sendmail $fflag \"$to\">/dev/null 2>&1") || &html_error("cannot run sendmail: $!");
96 # redirect above so it won't mess up the http header, eval{} works too.
97 @@ -284,6 +285,23 @@
98 ### -n option should not be used, since we are sending to aliases.
99 print POUT "$header";
100 close (POUT);
101 + } else {
102 + eval 'use Net::SMTP;';
103 + $smtp = Net::SMTP->new($mailhost,
104 + Timeout => 30); # seconds
105 + if ($smtp) {
106 + $smtp->mail($from);
107 + for $user (split(/,/, $to)) {
108 + $smtp->to($user);
109 + }
110 + $smtp->data();
111 + $smtp->datasend($header);
112 + $smtp->dataend();
113 + $smtp->quit;
114 + } else {
115 + &html_error("sendMail: SMTP connect to $mailhost failed");
116 + }
117 + }
118 };
119 &html_error("sendMail: $@") if $@;
120 }