mail.pm 1.22 KB
Newer Older
1 2 3 4
package mail;
use strict;

use Dancer ':syntax';
5 6
use Email::Sender::Simple qw(sendmail);
use Email::Simple;
7 8 9 10 11 12 13 14 15 16 17 18 19

sub send_welcome_mail {
	my %args = @_;
	my $username  = $args{member}->username;
	my $recipient = $args{member}->mail;

	info "Sending welcome for $username to $recipient";

	my $msg = template('welcome_mail', {
		password_link => 'https://members.gnugen.ch' . $args{password_link},
		member_link => 'https://members.gnugen.ch/member/' . $username,
	}, {layout => undef});

20 21 22 23 24 25 26 27 28 29 30
	my $mail = Email::Simple->create(
		header => [
			From    => 'comite@gnugen.ch',
			To      => $recipient,
			Bcc     => 'comite@gnugen.ch',
			Subject => 'Welcome to GNU Generation',
		],
		body => $msg,
	);

	sendmail($mail);
31 32 33 34 35 36 37 38 39 40
}

sub send_password_reset {
	my %args = @_;
	my $username  = $args{member}->username;
	my $recipient = $args{member}->mail;

	info "Sending password reset link form $username to $recipient";

	my $msg = template('password_reset_mail', {
41
		reset_link => 'https://members.gnugen.ch' . $args{password_link},
42 43
	}, {layout => undef});

44 45 46 47 48 49 50 51 52 53
	my $mail = Email::Simple->create(
		header => [
			From    => 'root@gnugen.ch',
			To      => $recipient,
			Subject => 'GNU Generation password reset',
		],
		body => $msg,
	);

	sendmail($mail);
54 55 56
}

1;