es wird ja ein PHP-Mailer mit Contenido ausgeliefert und sicher werden auch nahezu alle Seiten irgendeine Form eines Kontaktformulars mitbringen. Deshalb fände ich es gut, wenn man eine Funktion zur Verifikation von E-Mails direkt in die Contenido-Bibliotheken aufnehmen könnte (der Check in contenido/classes/class.form.php ist leider nicht geeignet den kompletten RFC abzudecken).
Ich würde folgenden Code vorschlagen:
Code: Alles auswählen
<?php
/*
* A function for verifying an e-mail address.
* Copyright © 2009 Kai Wasserbäch <kai@dev.carbon-project.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
function verifyEmailString( $sEMailToCheck ) {
//
// Check for RFC conformance.
//
if( filter_var($sEMailToCheck, FILTER_VALIDATE_EMAIL) === false ) {
return false;
}
//
// Check for MX or ANY record in DNS.
//
$sEmailHost = substr( strstr( $sEMailToCheck, '@'), 1).'.';
if( !getmxrr( $sEMailHost, $tmpArray ) && !checkdnsrr( $sEmailHost, 'ANY' ) ) {
return false;
}
// no failed tests
return true;
}
?>
Kai
P.S.: Der »isNotEmpty()«-Check in der o.g. PHP-Datei sollte doch hoffentlich so aussehen:
Code: Alles auswählen
function isNotEmpty($value) {
return !empty($value);
} // end function