aboutsummaryrefslogtreecommitdiffstats
path: root/fripost-adduser
diff options
context:
space:
mode:
authorGustav Eek <gustav.eek@fripost.org>2011-05-14 13:41:47 +0200
committerGustav Eek <gustav.eek@fripost.org>2011-05-14 13:41:47 +0200
commite14bd8eea4ad519e36a56dc868ed2e9effe1295e (patch)
tree1f4e6441be3602fa596b8564cc893b464580c503 /fripost-adduser
parent16ed1260dd2433d9c25cd550a06c175093416f58 (diff)
parentab34b78c7b247436a3d10d89b5f029fbe093ffe5 (diff)
Merge branch 'master' of https://github.com/skangas/fripost-tools
Diffstat (limited to 'fripost-adduser')
-rwxr-xr-xfripost-adduser33
1 files changed, 20 insertions, 13 deletions
diff --git a/fripost-adduser b/fripost-adduser
index ba97cdf..db312a2 100755
--- a/fripost-adduser
+++ b/fripost-adduser
@@ -1,8 +1,9 @@
#!/usr/bin/perl
use 5.010_000;
-use warnings;
use strict;
+use warnings;
+use utf8;
=head1 NAME
@@ -10,12 +11,11 @@ fripost-adduser - Add a new mailbox to the system
=cut
-our $VERSION = '0.02';
-
use FindBin qw($Bin);
use lib "$Bin/lib";
use Data::Dumper;
+use Encode qw(encode);
use File::Slurp qw(slurp);
use Fripost::Password;
use Fripost::Prompt;
@@ -51,7 +51,6 @@ my $schema = Fripost::Schema->connect(
my $user;
{
my $username = prompt_email("New username: ", 'is_user');
- my $name = prompt "Full (real) name: ";
my $domain = (split /\@/, $username)[1];
my $maildir = "$domain/". (split /\@/, $username)[0] . "/Maildir/"; # trailing slash important
my $active = 1;
@@ -59,7 +58,6 @@ my $user;
$user = {
username => $username,
- name => $name,
domain => $domain,
maildir => $maildir,
active => $active,
@@ -67,7 +65,6 @@ my $user;
};
say "User name: $user->{username}";
- say "Real name: $user->{name}";
say "Password: (hidden)";
confirm_or_abort();
@@ -94,8 +91,8 @@ my $tt = Template->new({
}) || die "$Template::ERROR\n";
my $msg = MIME::Lite->new(
- From => 'Friposts administratörer <admin@fripost.org>',
- Subject => "=?UTF-8?B?" . encode_base64('Välkommen till Fripost!' . "?=",
+ From => encode('MIME-Q', 'Friposts administratörer') . ' <admin@fripost.org>',
+ Subject => encode('MIME-Q', 'Välkommen till Fripost!'),
Encoding => 'quoted-printable',
);
@@ -105,15 +102,15 @@ $msg->attr('content-type.charset' => 'utf-8');
{
my ($vars, $data);
$vars = {};
+
$tt->process('new_user_mail.tt', $vars, \$data)
|| die $tt->error(), '\n';
-
- $msg->replace(To => $user->{username});
$msg->data($data);
+ $msg->replace(To => $user->{username});
unless ($conf->{pretend}) {
- $msg->send() unless $conf->{pretend};;
+ $msg->send() unless $conf->{pretend};
say "Sent welcome message.";
}
dsay "-----------------------------------";
@@ -129,11 +126,10 @@ $msg->attr('content-type.charset' => 'utf-8');
$vars = {
user => $user->{username},
pass => $user->{password},
- real => $user->{name},
};
+
$tt->process('user_info.tt', $vars, \$data)
|| die $tt->error(), '\n';
-
$msg->data($data);
dsay "-----------------------------------";
@@ -145,6 +141,7 @@ $msg->attr('content-type.charset' => 'utf-8');
confirm_or_abort("Send email with login information? ");
my $to = prompt_email("Where should the email be sent? ");
$msg->replace(To => $to);
+
if (!$conf->{pretend}) {
$msg->send;
say "Credentials sent.";
@@ -154,6 +151,16 @@ $msg->attr('content-type.charset' => 'utf-8');
}
}
+### Subscribe user to announce-list
+{
+ confirm_or_abort("Subscribe user to announce mailing list? ");
+ $msg->replace(From => $user->{username});
+ $msg->replace(To => 'announce-subscribe@lists.fripost.org');
+ $msg->replace(Subject => '');
+ $msg->replace(Data => '');
+ $msg->send();
+}
+
=head1 AUTHOR
Stefan Kangas C<< <skangas at skangas.se> >>