@@ -34,34 +34,50 @@ if ($in{'update'}) {
34
34
&webmin_log(" members" , undef , $in {' name' });
35
35
}
36
36
elsif ($in {' add' }) {
37
- # call majordomo to subscribe an address
37
+ # call send_mail to subscribe an address
38
38
$pass || &error($text {' members_esub' });
39
39
$in {' addr_a' } =~ / ^(\S +)\@ (\S +)\. (\S +)$ / ||
40
40
&error($text {' members_esubaddr' });
41
- open (WRAPPER, " |$wrapper_path majordomo" );
42
- printf WRAPPER " From: %s \n\n " ,
43
- $owner ? $owner : $in {' addr_a' };
44
- print WRAPPER " approve $pass subscribe $in {'name'} $in {'addr_a'}\n\n " ;
45
- close (WRAPPER);
46
- sleep (1);
41
+ $mail =sprintf (" From: %s \n To: %s \n Subject: subcribe\n\n " ,
42
+ $owner ? $owner : $in {' addr_a' }, " majordomo" );
43
+ $mail .= " approve $pass subscribe $in {'name'} $in {'addr_a'}\n\n " ;
44
+ &send_mail($mail );
47
45
&unlock_file($list -> {' members' });
48
46
&webmin_log(" subscribe" , undef , $in {' name' },
49
47
{ ' addr' => $in {' addr_a' } });
50
48
}
51
49
elsif ($in {' remove' }) {
52
- # call majordomo to unsubscribe an address
50
+ # call send_mail to unsubscribe an address
53
51
$pass || &error($text {' members_eunsub' });
54
52
$in {' addr_r' } =~ / ^(\S +)\@ (\S +)\. (\S +)$ / ||
55
53
&error($text {' members_eunsubaddr' });
56
- open (WRAPPER, " |$wrapper_path majordomo" );
57
- printf WRAPPER " From: %s \n\n " ,
58
- $owner ? $owner : $in {' addr_r' };
59
- print WRAPPER " approve $pass unsubscribe $in {'name'} $in {'addr_r'}\n\n " ;
60
- close (WRAPPER);
61
- sleep (1);
54
+ $mail =sprintf (" From: %s \n To: %s \n Subject: unsubcribe\n\n " ,
55
+ $owner ? $owner : $in {' addr_a' }, " majordomo" );
56
+ $mail .= " approve $pass unsubscribe $in {'name'} $in {'addr_r'}\n\n " ;
57
+ &send_mail($mail );
62
58
&unlock_file($list -> {' members' });
63
59
&webmin_log(" unsubscribe" , undef , $in {' name' },
64
60
{ ' addr' => $in {' addr_r' } });
65
61
}
66
62
&redirect(" edit_list.cgi?name=$in {'name'}" );
67
63
64
+ sub send_mail
65
+ {
66
+ local $sent ,$mail =$_ [0];
67
+ if (!$sent ) {
68
+ # Try to send the email by calling sendmail -t
69
+ %sconfig = &foreign_config(" sendmail" );
70
+ $sendmail = $sconfig {' sendmail_path' } ? $sconfig {' sendmail_path' }
71
+ : &has_command(" sendmail" );
72
+ if (-x $sendmail && open (MAIL, " | $sendmail -t" )) {
73
+ print MAIL $mail ;
74
+ if (close (MAIL)) {
75
+ $sent = 2;
76
+ }
77
+ }
78
+ }
79
+
80
+ if (!$sent ) {
81
+ &error($text {' global_esendmail' }, " " );
82
+ }
83
+ }
0 commit comments