From 419487240780f1e789c8f7d948167feb8f010e03 Mon Sep 17 00:00:00 2001 From: Stefan Kangas Date: Sun, 20 Mar 2011 23:13:01 +0100 Subject: Fix silly bug in last commit --- fripost-adduser | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/fripost-adduser b/fripost-adduser index ba97cdf..8f2486a 100755 --- a/fripost-adduser +++ b/fripost-adduser @@ -105,12 +105,12 @@ $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};; @@ -131,9 +131,9 @@ $msg->attr('content-type.charset' => 'utf-8'); pass => $user->{password}, real => $user->{name}, }; + $tt->process('user_info.tt', $vars, \$data) || die $tt->error(), '\n'; - $msg->data($data); dsay "-----------------------------------"; @@ -145,6 +145,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."; -- cgit v1.2.3 From c2d0d8bc220db97f11d53460b3de3e7e90850b91 Mon Sep 17 00:00:00 2001 From: Stefan Kangas Date: Sun, 20 Mar 2011 23:54:10 +0100 Subject: Use correct encoding in adduser mail --- fripost-adduser | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/fripost-adduser b/fripost-adduser index 8f2486a..368d4e4 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; @@ -94,8 +94,8 @@ my $tt = Template->new({ }) || die "$Template::ERROR\n"; my $msg = MIME::Lite->new( - From => 'Friposts administratörer ', - Subject => "=?UTF-8?B?" . encode_base64('Välkommen till Fripost!' . "?=", + From => encode('MIME-Q', 'Friposts administratörer') . ' ', + Subject => encode('MIME-Q', 'Välkommen till Fripost!'), Encoding => 'quoted-printable', ); -- cgit v1.2.3 From d08d7c879d1224b1bafb068996c760f4fa5d8957 Mon Sep 17 00:00:00 2001 From: Stefan Kangas Date: Sun, 20 Mar 2011 23:54:22 +0100 Subject: Subscribe new users to announce mailing list --- fripost-adduser | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/fripost-adduser b/fripost-adduser index 368d4e4..e96c5f3 100755 --- a/fripost-adduser +++ b/fripost-adduser @@ -155,6 +155,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<< >> -- cgit v1.2.3 From 701456b6047b1d698ee3a8173249afaf2679e20f Mon Sep 17 00:00:00 2001 From: Stefan Kangas Date: Mon, 21 Mar 2011 00:01:44 +0100 Subject: Update new member letter --- templ/user_info.tt | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/templ/user_info.tt b/templ/user_info.tt index e6b778f..6a375e5 100644 --- a/templ/user_info.tt +++ b/templ/user_info.tt @@ -1,14 +1,11 @@ -Hej [% real %], +Hej, -Du är nu tillagd på Friposts system. +Här kommer dina inloggningsuppgifter till Friposts system. Användarnamn: [% user %] -Lösenord [% pass %] +Lösenord: [% pass %] -Tänk på att vara försiktig med dina uppgifter. Spara en kopia av det här mailet -på en säker plats. - -Du kan logga in på: +Du kan logga in direkt på: https://mail.fripost.org/ @@ -16,12 +13,17 @@ Frågor gällande ditt konto kan du ta direkt med administratörerna. admin@fripost.org -Du kan hitta information om hur du konfigurerar din e-postklient för Fripost på -vår wiki. Vi försöker bygga upp medlemswikin till att bli den bästa resursen -för intern information kring föreningen. Du får gärna hjälpa till! +Vi försöker bygga upp medlemswikin till att bli den bästa resursen för intern +information kring föreningen. Du får gärna hjälpa till! http://wiki.fripost.org/ +Tänk på att vara försiktig med dina uppgifter. Spara gärna en kopia av det här +mailet på en säker plats. + +Tyvärr finns det just nu inget smidigt sätt att byta sitt lösenord på. Vi jobbar +på det. + Ha kul! Med vänliga hälsningar, -- cgit v1.2.3 From 7a522692d79d68d276fad9edf233530f68dadb7e Mon Sep 17 00:00:00 2001 From: Stefan Kangas Date: Mon, 21 Mar 2011 22:24:24 +0100 Subject: Send confirmation when adding new alias --- fripost-adduser | 2 +- fripost-newalias | 57 ++++++++++++++++++++++++++++++++++++++++++++---------- templ/new_alias.tt | 12 ++++++++++++ 3 files changed, 60 insertions(+), 11 deletions(-) create mode 100644 templ/new_alias.tt diff --git a/fripost-adduser b/fripost-adduser index e96c5f3..b72ae30 100755 --- a/fripost-adduser +++ b/fripost-adduser @@ -113,7 +113,7 @@ $msg->attr('content-type.charset' => 'utf-8'); $msg->replace(To => $user->{username}); unless ($conf->{pretend}) { - $msg->send() unless $conf->{pretend};; + $msg->send() unless $conf->{pretend}; say "Sent welcome message."; } dsay "-----------------------------------"; diff --git a/fripost-newalias b/fripost-newalias index fb9acec..ecfa4bf 100755 --- a/fripost-newalias +++ b/fripost-newalias @@ -1,8 +1,9 @@ #!/usr/bin/perl use 5.010_000; -use warnings; use strict; +use warnings; +use utf8; =head1 NAME @@ -18,13 +19,17 @@ fripost-newalias GOTO FROM... use FindBin qw($Bin); use lib "$Bin/lib"; -use Data::Dumper; +use Encode qw(encode); use Email::Valid; use Fripost::Password; use Fripost::Prompt; use Fripost::Schema; use IO::Prompt; use Getopt::Long; +use MIME::Base64; +use MIME::Lite; +use MIME::QuotedPrint; +use Template; use YAML::Syck; ## Get command line options @@ -48,11 +53,6 @@ my @addr = @ARGV; $goto //= prompt_username("Alias goto address: "); @addr || push @addr, prompt "Alias address: "; -if ($conf->{pretend}) { - say "Nothing to do since we are pretending..."; - exit 0; -} - # Show goto adress say "goto adress: $goto"; @@ -84,15 +84,52 @@ for my $addr (@addr) { goto => $goto, domain => (split /\@/, $addr)[1], }); - $db_alias->insert; - - say "New alias added from $addr to $goto."; + if (!$conf->{pretend}) { + $db_alias->insert; + say "New alias added from $addr to $goto."; + } else { + say "Pretending, will not add alias." + } } else { say "There already exists an alias for $addr."; } } +### Prepare sending emails +my $tt = Template->new({ + INCLUDE_PATH => "$Bin/templ", + INTERPOLATE => 1, +}) || die "$Template::ERROR\n"; + +my $msg = MIME::Lite->new( + From => encode('MIME-Q', 'Friposts administratörer') . ' ', + Subject => encode('MIME-Q', 'Nya alias till din inkorg'), + Encoding => 'quoted-printable', +); + +{ + my ($vars, $data); + $vars = { + addrs => \@addr, + }; + + $tt->process('new_alias.tt', $vars, \$data) + || die $tt->error(), '\n'; + $msg->data($data); + + $msg->replace(To => $goto); + + if (!$conf->{pretend}) { + confirm_or_abort("Send confirmation? "); + $msg->send; + say "Sent verification."; + } + else { + say "Pretending, will not send verification."; + } +} + =head1 AUTHOR Stefan Kangas C<< >> diff --git a/templ/new_alias.tt b/templ/new_alias.tt new file mode 100644 index 0000000..969e6ad --- /dev/null +++ b/templ/new_alias.tt @@ -0,0 +1,12 @@ +Hej, + +Följande adresser går nu till den här inkorgen: + +[% FOREACH addr IN addrs -%] + [% addr %] +[% END -%] + +Hör av dig om något är fel eller annars är oklart. + +Med vänliga hälsningar, +Administratörerna -- cgit v1.2.3 From c7701570975feab6dd268802c6f552381d691529 Mon Sep 17 00:00:00 2001 From: Stefan Kangas Date: Mon, 21 Mar 2011 22:31:02 +0100 Subject: Updates --- fripost-newalias | 4 ++-- fripost-newdomain | 10 ++++------ lib/Fripost/Prompt.pm | 4 ++-- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/fripost-newalias b/fripost-newalias index ecfa4bf..4592522 100755 --- a/fripost-newalias +++ b/fripost-newalias @@ -50,8 +50,8 @@ my $schema = Fripost::Schema->connect( # Get information my $goto = fix_username(shift @ARGV); my @addr = @ARGV; -$goto //= prompt_username("Alias goto address: "); -@addr || push @addr, prompt "Alias address: "; +$goto //= prompt_email("Alias goto address: ", 'is_user'); +@addr || push @addr, prompt "Alias from address: "; # Show goto adress say "goto adress: $goto"; diff --git a/fripost-newdomain b/fripost-newdomain index cf781ed..99c2ce3 100755 --- a/fripost-newdomain +++ b/fripost-newdomain @@ -3,6 +3,7 @@ use 5.010_000; use warnings; use strict; +use utf8; =head1 NAME @@ -10,8 +11,6 @@ fripost-newdomain - Add a new domain to the system =cut -our $VERSION = '0.01'; - use FindBin qw($Bin); use lib "$Bin/lib"; @@ -27,7 +26,7 @@ use YAML::Syck; our $conf = LoadFile('default.yml'); GetOptions( - 'dbi_dsn' => \$conf->{dbi_dsn}, + 'dbi_dsn' => \$conf->{dbi_dsn}, 'admuser=s' => \$conf->{admuser}, 'admpass=s' => \$conf->{admpass}, 'pretend' => \$conf->{pretend}, @@ -38,13 +37,12 @@ my $schema = Fripost::Schema->connect( $conf->{dbi_dsn}, $conf->{admuser}, $conf->{admpass}, {} #\%dbi_params ); -say "Adding a new domain."; - my %domain; $domain{domain} = prompt "Domain name: "; -$domain{description} = prompt_username("User to associate domain with: "); +$domain{description} = prompt_email("Belongs to user: ", 'is_user'); ## TODO: Make sure the user does exists +## TODO: Warn if the user has a domain already if ($conf->{pretend}) { say "Nothing to do since we are only pretending..."; diff --git a/lib/Fripost/Prompt.pm b/lib/Fripost/Prompt.pm index b41f806..bbc554d 100755 --- a/lib/Fripost/Prompt.pm +++ b/lib/Fripost/Prompt.pm @@ -32,9 +32,9 @@ sub confirm_or_abort { sub fix_username { my ($nam) = @_; - if ($nam !~ /\@/) { + if (defined $nam && $nam !~ /\@/) { $nam .= '@fripost.org'; - say "Using username: $nam"; + say "Using $nam"; } return $nam; } -- cgit v1.2.3 From 5b378efb833e05912c94116fb18e2613755fde5c Mon Sep 17 00:00:00 2001 From: Stefan Kangas Date: Tue, 5 Apr 2011 21:44:03 +0200 Subject: Fix typo --- lib/Fripost/Prompt.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Fripost/Prompt.pm b/lib/Fripost/Prompt.pm index bbc554d..0a9d5c6 100755 --- a/lib/Fripost/Prompt.pm +++ b/lib/Fripost/Prompt.pm @@ -47,7 +47,7 @@ sub prompt_email { $email = prompt $msg; if ($is_username) { - $email = fix_username($email) + $email = fix_username($email); } if (!Email::Valid->address($email)) { -- cgit v1.2.3 From 205da09d85274f993fe7343b6517f96c2f2b78dc Mon Sep 17 00:00:00 2001 From: Stefan Kangas Date: Tue, 5 Apr 2011 22:12:10 +0200 Subject: Do not ask for real name when adding user --- fripost-adduser | 4 ---- 1 file changed, 4 deletions(-) diff --git a/fripost-adduser b/fripost-adduser index b72ae30..db312a2 100755 --- a/fripost-adduser +++ b/fripost-adduser @@ -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(); @@ -129,7 +126,6 @@ $msg->attr('content-type.charset' => 'utf-8'); $vars = { user => $user->{username}, pass => $user->{password}, - real => $user->{name}, }; $tt->process('user_info.tt', $vars, \$data) -- cgit v1.2.3 From ab34b78c7b247436a3d10d89b5f029fbe093ffe5 Mon Sep 17 00:00:00 2001 From: Stefan Kangas Date: Fri, 8 Apr 2011 15:56:30 +0200 Subject: fripost-passwd does not require username with host on command line --- fripost-passwd | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fripost-passwd b/fripost-passwd index c01ca4b..bb67e44 100755 --- a/fripost-passwd +++ b/fripost-passwd @@ -23,13 +23,13 @@ use YAML::Syck; our $conf = LoadFile('default.yml'); GetOptions( - 'dbi_dsn' => \$conf->{dbi_dsn}, + 'dbi_dsn' => \$conf->{dbi_dsn}, 'admuser=s' => \$conf->{admuser}, 'admpass=s' => \$conf->{admpass}, 'pretend' => \$conf->{pretend}, ) or die "Unable to get command line options."; -my $username = $ARGV[0]; +my $username = fix_username($ARGV[0]); $username //= prompt_email("New username: ", 'is_user'); my $password = prompt_password(); -- cgit v1.2.3