aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--INSTALL4
-rwxr-xr-xfripost-adduser25
-rwxr-xr-xfripost-newalias4
-rwxr-xr-xfripost-newdomain4
-rw-r--r--templ/new_user_mail.tt11
5 files changed, 26 insertions, 22 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 16f253c..0d65cf3 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';
@@ -21,16 +16,18 @@ 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
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
@@ -88,13 +85,27 @@ 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);
$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<< <skangas at skangas.se> >>
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';
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/