# Selima Website Content Management System # MailTo.pm: The e-mail hyperlink redirection form checker. # Copyright (c) 2004-2018 imacat. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # Author: imacat # First written: 2004-10-25 package Selima::Checker::MailTo; use 5.008; use strict; use warnings; use base qw(Selima::Checker); use Email::Valid qw(); use Selima::ShortCut; # _check_email: Check the submitted e-mail sub _check_email : method { local ($_, %_); my ($self, $form, $error); $self = $_[0]; $form = $self->{"form"}; # Check if it exists $error = $self->_missing("email"); return $error if defined $error; # Regularize it $self->_trim("email"); # Check if it is filled return {"msg"=>N_("Please fill in the e-mail.")} if $form->param("email") eq ""; # Un-mung e-mail to its original format $_ = $form->param("email"); s/ at /\@/; $form->param("email", $_); # Check the e-mail validity return {"msg"=>N_("Please fill in a valid e-mail address.")} if !Email::Valid->rfc822($form->param("email")); return {"msg"=>N_("The domain of this e-mail does not exists. Check if there is any typo in it.")} if !Email::Valid->mx($form->param("email")); # OK return; } return 1;