10 use Digest::SHA qw(sha256_hex);
12 my %conf = %main::conf;
13 my $staff = $conf{staff};
14 my $hostname = $conf{hostname};
15 my $mailfrom = $conf{mailfrom};
16 my $mailname = $conf{mailname};
17 main::cbind("msg", "-", "mail", \&mmail);
20 #dependencies for encrypt
21 unveil("/usr/bin/encrypt", "rx") or die "Unable to unveil $!";
22 #dependencies for mail
23 unveil("/usr/sbin/sendmail", "rx") or die "Unable to unveil $!";
24 unveil("/usr/lib/libutil.so.13.1", "r") or die "Unable to unveil $!";
25 unveil("/bin/sh", "rx") or die "Unable to unveil $!";
28 my ($bot, $nick, $host, $hand, $text) = @_;
29 if ($staff !~ /$nick/) { return; }
30 if ($text =~ /^([-_0-9a-zA-Z~@!\.]{3,})\s+([-_0-9a-zA-Z~@!\.]{3,})/) {
31 my ($from, $to) = ($1, $2);
32 if (mail($from, $to, "support", "alpha bravo", "charlie delta echo foxtrot")) {
33 main::putserv($bot, "PRIVMSG $nick :mail sent from $from to $to");
35 main::putserv($bot, "PRIVMSG $nick :ERROR: failed to send mail");
41 my( $from, $to, $fromname, $subject, $body )=@_;
47 Content-Type: text/plain; charset=us-ascii
48 Content-Disposition: inline
52 open(my $fh, "| /usr/sbin/sendmail -tv -F '$fromname' -f $from") or die "Could not send mail $!";
60 # my( $username, $password, $email, $service )=@_;
62 #From: support \<support\@ircnow.org\>
64 #Subject: Welcome to IRCNow!
66 #Content-Type: text/plain; charset=us-ascii
67 #Content-Disposition: inline
71 #Your account $username with password $password is now activated.
73 #For instructions on how to connect, please visit: https://ircnow.org
75 #For help, please visit our support channel on irc.ircnow.org #ircnow.
79 #open(my $fh, '| /usr/sbin/sendmail -tv -F support -f support@ircnow.org') or die "Could not send mail $!";
82 #open($fh, '>>', "$database") or die "Could not open file '$database' $!";
89 # my ($password, $username) = @_;
90 # my $encrypted = `encrypt $password`;
92 # my $line = "${username}\@ircnow.org:${encrypted}::::::userdb_quota_rule=*:storage=1G";
93 # $line =~ s{\$}{\\\$}g;
94 # my $line2 = "${username}\@ircnow.org vmail";
95 # my $line3 = "${username}: ${username}\@ircnow.org";
96 # `doas sh -c 'echo $line >> /etc/mail/passwd'`;
97 # `doas sh -c 'echo $line2 >> /etc/mail/virtuals'`;
98 # `doas sh -c 'echo $line3 >> /etc/mail/aliases'`;
99 # `doas rcctl restart smtpd`;
100 # `doas rcctl reload dovecot`;
103 1; # MUST BE LAST STATEMENT IN FILE