From f6943940ffc36b5d4f8109e3f0ab27bec19a68b1 Mon Sep 17 00:00:00 2001 From: Stefan Kangas Date: Fri, 11 Mar 2011 17:30:43 +0100 Subject: Fix bug --- fripost-adduser | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fripost-adduser b/fripost-adduser index 16f253c..1e3c08c 100755 --- a/fripost-adduser +++ b/fripost-adduser @@ -30,7 +30,7 @@ use YAML::Syck; # Prompt for user info sub read_user_info { - $username = prompt_username("New username: "); + my $username = prompt_username("New username: "); my $name = prompt "Full (real) name: "; my $domain = (split /\@/, $username)[1]; my $maildir = "$domain/". (split /\@/, $username)[0] . "/Maildir/"; # trailing slash important -- cgit v1.2.3 From 0dfd0f47ce5942e85aa8b270a4a9e6230339a32a Mon Sep 17 00:00:00 2001 From: Stefan Kangas Date: Fri, 11 Mar 2011 17:32:25 +0100 Subject: Remove some useless documentation --- fripost-adduser | 5 ----- fripost-newalias | 4 ---- fripost-newdomain | 4 ---- 3 files changed, 13 deletions(-) diff --git a/fripost-adduser b/fripost-adduser index 1e3c08c..e6bc5ab 100755 --- a/fripost-adduser +++ b/fripost-adduser @@ -8,11 +8,6 @@ use strict; fripost-adduser - Add a new mailbox to the system -=head1 DESCRIPTION - -This script eases the burden of adding a new user to the system. It simply adds -a new user to the database. - =cut our $VERSION = '0.02'; diff --git a/fripost-newalias b/fripost-newalias index 6074ded..313691f 100755 --- a/fripost-newalias +++ b/fripost-newalias @@ -8,10 +8,6 @@ use strict; fripost-newalias - Add a new alias to the system -=head1 DESCRIPTION - -This script eases the burden of adding a new alias to the system. - =cut our $VERSION = '0.01'; diff --git a/fripost-newdomain b/fripost-newdomain index 493cd3d..cf781ed 100755 --- a/fripost-newdomain +++ b/fripost-newdomain @@ -8,10 +8,6 @@ use strict; fripost-newdomain - Add a new domain to the system -=head1 DESCRIPTION - -This script eases the burden of adding a new domain to the system. - =cut our $VERSION = '0.01'; -- cgit v1.2.3 From f559605cb240edb57d1a0e0338b449e4ca767d51 Mon Sep 17 00:00:00 2001 From: Stefan Kangas Date: Fri, 11 Mar 2011 19:04:17 +0100 Subject: adduser: die if user already exists --- fripost-adduser | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/fripost-adduser b/fripost-adduser index e6bc5ab..e4a4298 100755 --- a/fripost-adduser +++ b/fripost-adduser @@ -83,7 +83,9 @@ if ($conf->{pretend}) { exit 0; } -## TODO: Make sure the user does not already exist +die "User already exists" + if ($schema->resultset('Mailbox')->search({ + username => $user->{username} })->count); ## Insert user into database my $db_user = $schema->resultset('Mailbox')->new($user); -- cgit v1.2.3 From 846ba6f0a5a36ec34b48d9ebe8076fc69a42ff2a Mon Sep 17 00:00:00 2001 From: Stefan Kangas Date: Fri, 11 Mar 2011 19:27:24 +0100 Subject: send email to new user --- INSTALL | 4 ++-- fripost-adduser | 14 ++++++++++++++ templ/new_user_mail.tt | 11 ++++++----- 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/INSTALL b/INSTALL index 356d726..95a169a 100644 --- a/INSTALL +++ b/INSTALL @@ -3,5 +3,5 @@ You need several cpan modules to use these scripts. If you use Debian GNU/Linux, you can install them like so: aptitude install -R libdatetime-format-mysql-perl libdatetime-perl \ -libdbix-class-perl libemail-valid-perl libio-prompt-perl libstring-mkpasswd-perl \ -libyaml-syck-perl +libdbix-class-perl libemail-valid-perl libfile-slurp-perl libio-prompt-perl \ +libmime-lite-perl libstring-mkpasswd-perl libyaml-syck-perl diff --git a/fripost-adduser b/fripost-adduser index e4a4298..0d65cf3 100755 --- a/fripost-adduser +++ b/fripost-adduser @@ -16,11 +16,13 @@ use FindBin qw($Bin); use lib "$Bin/lib"; use Data::Dumper; +use File::Slurp qw(slurp); use Fripost::Password; use Fripost::Prompt; use Fripost::Schema; use IO::Prompt; use Getopt::Long; +use MIME::Lite; use YAML::Syck; # Prompt for user info @@ -92,6 +94,18 @@ my $db_user = $schema->resultset('Mailbox')->new($user); $db_user->insert; say "New account $user->{username} added."; +## Send email +my $msg = MIME::Lite->new( + From => 'admin@fripost.org', + To => $user->{username}, + Subject => 'Välkommen till Fripost!', + Data => slurp('templ/new_user_mail.tt'), # TODO: actually use TT +); +$msg->send(); + +say "Sent welcome message: "; +say $message->as_text; + =head1 AUTHOR Stefan Kangas C<< >> diff --git a/templ/new_user_mail.tt b/templ/new_user_mail.tt index 0d060a6..0a1319b 100644 --- a/templ/new_user_mail.tt +++ b/templ/new_user_mail.tt @@ -4,15 +4,16 @@ Allmänna frågor kring programmen, webmailen eller konfiguration av e-postprogram tas bäst på e-postlistan så att svaren kan komma alla till del. - members@lists.fripost.org +Du kan bli medlem genom att skicka ett mail till -Frågor gällande just ditt konto kan du ta direkt med -administratörerna. + members-subscribe@lists.fripost.org + +Frågor gällande specifikt ditt konto kan du ta direkt med administratörerna. admin@lists.fripost.org -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/ -- cgit v1.2.3