Apache-App-Mercury
view release on metacpan or search on metacpan
} elsif ($q->param('message_center')) {
$self->{'state'} = 'message_center';
$self->show_mail_center;
$controller->sitemark('/messaging');
} elsif ($self->{'state'} eq 'edit_settings' or $args{'edit_mail_prefs'}) {
if ($q->param('add_box')) {
if ($self->verify_new_mailbox($q->param('new_box'))) {
$self->add_new_mailbox($q->param('new_box'));
$self->checkmail;
$q->delete('new_box');
}
} elsif ($q->param('delete_box')) {
$self->delete_mailbox($q->param('custom_box'),
$q->param('delete_mail_in_box'));
$self->checkmail;
$q->delete('custom_box');
$q->delete('delete_mail_in_box');
} elsif ($self->{'state'} eq 'compose_message') {
$self->save_compose_message_fields;
$controller->sitemark('/messaging.compose');
$controller->infomsg("You must take action on your existing composition before creating a transaction-related message.")
if ($q->param('reply_trans') or $q->param('compose_trans'));
if ($q->param('preview')) {
my ($fail, $recip, $recip_desc) =
$self->verify_recipient($self->{compose_msg}->{'sent_to'}, 1);
unless ($fail) {
$self->{compose_msg}->{'sent_to'} = $recip;
$self->{compose_msg}->{'recipient_desc'} = $recip_desc;
$self->{'state'} = 'preview_message';
$self->show_mail_preview;
$controller->sitemark('/messaging.preview');
return;
}
} elsif ($q->param('return')) {
$self->{'state'} = 'compose_message';
$self->show_mail_compose;
$controller->sitemark('/messaging.compose');
} elsif ($args{'mailto'}) {
if (ref $self->{compose_msg} ne "Apache::App::Mercury::Message") {
$self->reset_compose_message;
my ($fail, $recip, $recip_desc) =
$self->verify_recipient($args{'mailto'}, 1);
unless ($fail) {
$self->{compose_msg}->{'action'} = 'mailto';
$self->{compose_msg}->{'sent_to'} = $recip;
$self->{compose_msg}->{'recipient_desc'} = $recip_desc;
}
} else {
$controller->infomsg("You must take action on your saved composition before creating a new message.");
}
$self->{'state'} = 'compose_message';
$self->{compose_msg}->{'transcode'} = '';
$self->{compose_msg}->{'body'} = '';
delete $self->{compose_msg}->{'Attachments'};
}
sub set_compose_reply {
my ($self, $origmsg) = @_;
my $new = $self->{compose_msg};
my ($fail, $recip, $recip_desc) =
$self->verify_recipient($origmsg->{'sender'}, 1);
return 0 if $fail;
$new->{'action'} = 'reply';
$new->{'subject'} = "Re: ".$origmsg->{'subject'};
$new->{'sent_to'} = $recip;
$new->{'recipient_desc'} = $recip_desc;
$new->{'transcode'} = $origmsg->{'transcode'};
$new->{'body'} = $origmsg->{'sender'}." wrote:\n\n".$origmsg->{'body'};
$new->{'body'} =~ s/^/> /gm;
$new->{'body'} = "\n\n\n".$new->{'body'};
$new->{'recipient_desc'} = '';
$new->{'transcode'} = $origmsg->{'transcode'};
$new->{'body'} = $origmsg->{'body'};
$new->{'security'} = $origmsg->{'security'};
$new->{'security_fixed'} = 1 if $origmsg->{'security_fixed'};
$new->{'Attachments'} = dclone $origmsg->{'Attachments'}
if ref $origmsg->{'Attachments'} eq "ARRAY";
}
sub verify_recipient {
my ($self, $recip, $show_fail_message) = @_;
my $q = $self->{q};
my $controller = $self->{controller};
# remove all whitespace (user_names can't have any)
$recip =~ s/\s//g;
$self->warn("->verify_recipient: checking '$recip'.");
if (!$recip) {
$controller->infomsg("You must enter a recipient.") if $show_fail_message;
return ('fail', undef, undef);
} elsif ($recip eq $self->{user_manager}->userprofile('user')) {
return (0, $self->{user_manager}->userprofile('user'),
"(".$self->{user_manager}->userprofile('user_desc').")");
} else {
my @recps = split(';', $recip);
my @chk_recip = $self->{user_manager}->get_userinfo(@recps);
my ($usrs, $descript);
# tell message object to store itself
if ($compose->store) {
$self->{controller}->infomsg(!$is_memo ? "Your message has been sent." : "Your memo has been committed.");
delete $self->{compose_msg};
} else {
$self->{controller}->infomsg("There was an error ".(!$is_memo ? "sending your message" : "committing your memo").". Please contact technical support.");
}
}
sub verify_new_mailbox {
my ($self, $new_box) = @_;
my $controller = $self->{controller};
# make sure there is a new_box
if (!$new_box) {
$controller->infomsg("You did not enter a name for your new mailbox!");
return 0;
}
# make sure there are no commas
if (($new_box) =~ (m/,/)) {
Mercury/SMTP_Message.pm view on Meta::CPAN
my %autoforw =
( 'low' => $usermgr->auto_forward('low'),
'medium' => $usermgr->auto_forward('medium'),
'high' => $usermgr->auto_forward('high') );
$self->{'address'} =
($usermgr->get_userinfo($self->{'recipient'}))[0]->{e_mail};
$self->warn("->send_by_e_mail: attempting send of msgid='".$self->{'id'}."', user='".$self->{'recipient'}."', address='".$self->{'address'}."', msg_security='".$self->{'security'}."', autofwd='".$autoforw{$self->{'security'}}."'");
# verify recipient has a valid e-mail address registered
unless ($self->{'address'} =~ m/\@/) {
$self->set_smtp_status;
return 0;
}
# check recipient's auto-forward settings
if ($autoforw{$self->{'security'}} eq 'message') {
my $msg = $self->to_mime($self->{'address'});
$self->warn("->send_by_e_mail: sending full message to <".$self->{'address'}.">:");
eval {
( run in 0.596 second using v1.01-cache-2.11-cpan-5467b0d2c73 )