Blame
Date:
Sun Dec 27 01:56:09 2020 UTC
Message:
Updated p5-Class-DBI-SQLite-0.11p2
001
2020-10-11
jrmu
#!/usr/bin/perl
002
2020-10-11
jrmu
003
2020-10-11
jrmu
package Mail;
004
2020-10-11
jrmu
005
2020-10-11
jrmu
use strict;
006
2020-10-11
jrmu
use warnings;
007
2020-10-11
jrmu
use OpenBSD::Pledge;
008
2020-10-11
jrmu
use OpenBSD::Unveil;
009
2020-10-11
jrmu
use MIME::Base64;
010
2020-10-11
jrmu
use Digest::SHA qw(sha256_hex);
011
2020-10-11
jrmu
012
2020-11-15
jrmu
my %conf = %main::conf;
013
2020-11-15
jrmu
my $staff = $conf{staff};
014
2020-11-15
jrmu
my $hostname = $conf{hostname};
015
2020-11-15
jrmu
my $mailfrom = $conf{mailfrom};
016
2020-11-15
jrmu
my $mailname = $conf{mailname};
017
2020-11-15
jrmu
main::cbind("msg", "-", "mail", \&mmail);
018
2020-10-11
jrmu
019
2020-10-11
jrmu
sub init {
020
2020-10-11
jrmu
#dependencies for encrypt
021
2020-10-11
jrmu
unveil("/usr/bin/encrypt", "rx") or die "Unable to unveil $!";
022
2020-10-11
jrmu
#dependencies for mail
023
2020-10-11
jrmu
unveil("/usr/sbin/sendmail", "rx") or die "Unable to unveil $!";
024
2020-10-11
jrmu
unveil("/usr/lib/libutil.so.13.1", "r") or die "Unable to unveil $!";
025
2020-10-11
jrmu
unveil("/bin/sh", "rx") or die "Unable to unveil $!";
026
2020-10-11
jrmu
}
027
2020-10-11
jrmu
sub mmail {
028
2020-10-11
jrmu
my ($bot, $nick, $host, $hand, $text) = @_;
029
2020-10-11
jrmu
if ($staff !~ /$nick/) { return; }
030
2020-10-11
jrmu
if ($text =~ /^([-_0-9a-zA-Z~@!\.]{3,})\s+([-_0-9a-zA-Z~@!\.]{3,})/) {
031
2020-10-11
jrmu
my ($from, $to) = ($1, $2);
032
2020-10-11
jrmu
if (mail($from, $to, "support", "alpha bravo", "charlie delta echo foxtrot")) {
033
2020-10-11
jrmu
main::putserv($bot, "PRIVMSG $nick :mail sent from $from to $to");
034
2020-10-11
jrmu
} else {
035
2020-10-11
jrmu
main::putserv($bot, "PRIVMSG $nick :ERROR: failed to send mail");
036
2020-10-11
jrmu
}
037
2020-10-11
jrmu
}
038
2020-10-11
jrmu
}
039
2020-10-11
jrmu
040
2020-10-11
jrmu
sub mail {
041
2020-10-11
jrmu
my( $from, $to, $fromname, $subject, $body )=@_;
042
2020-10-11
jrmu
my $msg = <<"EOF";
043
2020-10-11
jrmu
From: $from
044
2020-10-11
jrmu
To: $to
045
2020-10-11
jrmu
Subject: $subject
046
2020-10-11
jrmu
MIME-Version: 1.0
047
2020-10-11
jrmu
Content-Type: text/plain; charset=us-ascii
048
2020-10-11
jrmu
Content-Disposition: inline
049
2020-10-11
jrmu
050
2020-10-11
jrmu
$body
051
2020-10-11
jrmu
EOF
052
2020-11-15
jrmu
open(my $fh, "| /usr/sbin/sendmail -tv -F '$fromname' -f $from") or die "Could not send mail $!";
053
2020-10-11
jrmu
print $fh $msg;
054
2020-10-11
jrmu
close $fh;
055
2020-10-11
jrmu
return "true";
056
2020-10-11
jrmu
}
057
2020-10-11
jrmu
058
2020-10-11
jrmu
059
2020-10-11
jrmu
#sub mailfinish {
060
2020-10-11
jrmu
# my( $username, $password, $email, $service )=@_;
061
2020-10-11
jrmu
#my $msg = <<"EOF";
062
2020-10-11
jrmu
#From: support \<support\@ircnow.org\>
063
2020-10-11
jrmu
#To: $email
064
2020-10-11
jrmu
#Subject: Welcome to IRCNow!
065
2020-10-11
jrmu
#MIME-Version: 1.0
066
2020-10-11
jrmu
#Content-Type: text/plain; charset=us-ascii
067
2020-10-11
jrmu
#Content-Disposition: inline
068
2020-10-11
jrmu
#
069
2020-10-11
jrmu
#Welcome to IRCNow!
070
2020-10-11
jrmu
#
071
2020-10-11
jrmu
#Your account $username with password $password is now activated.
072
2020-10-11
jrmu
#
073
2020-10-11
jrmu
#For instructions on how to connect, please visit: https://ircnow.org
074
2020-10-11
jrmu
#
075
2020-10-11
jrmu
#For help, please visit our support channel on irc.ircnow.org #ircnow.
076
2020-10-11
jrmu
#
077
2020-10-11
jrmu
#IRCNow
078
2020-10-11
jrmu
#EOF
079
2020-10-11
jrmu
#open(my $fh, '| /usr/sbin/sendmail -tv -F support -f support@ircnow.org') or die "Could not send mail $!";
080
2020-10-11
jrmu
#print $fh $msg;
081
2020-10-11
jrmu
#close $fh;
082
2020-10-11
jrmu
#open($fh, '>>', "$database") or die "Could not open file '$database' $!";
083
2020-10-11
jrmu
#print $fh $msg;
084
2020-10-11
jrmu
#close $fh;
085
2020-10-11
jrmu
#}
086
2020-10-11
jrmu
#
087
2020-10-11
jrmu
088
2020-10-11
jrmu
#sub createmail {
089
2020-10-11
jrmu
# my ($password, $username) = @_;
090
2020-10-11
jrmu
# my $encrypted = `encrypt $password`;
091
2020-10-11
jrmu
# chomp($encrypted);
092
2020-10-11
jrmu
# my $line = "${username}\@ircnow.org:${encrypted}::::::userdb_quota_rule=*:storage=1G";
093
2020-10-11
jrmu
# $line =~ s{\$}{\\\$}g;
094
2020-10-11
jrmu
# my $line2 = "${username}\@ircnow.org vmail";
095
2020-10-11
jrmu
# my $line3 = "${username}: ${username}\@ircnow.org";
096
2020-10-11
jrmu
# `doas sh -c 'echo $line >> /etc/mail/passwd'`;
097
2020-10-11
jrmu
# `doas sh -c 'echo $line2 >> /etc/mail/virtuals'`;
098
2020-10-11
jrmu
# `doas sh -c 'echo $line3 >> /etc/mail/aliases'`;
099
2020-10-11
jrmu
# `doas rcctl restart smtpd`;
100
2020-10-11
jrmu
# `doas rcctl reload dovecot`;
101
2020-10-11
jrmu
#}
102
2020-10-11
jrmu
103
2020-10-11
jrmu
1; # MUST BE LAST STATEMENT IN FILE