-
-
Save richartkeil/2bf82215d2ca2d0da938 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function sendMail($mail_to, $text = null, $title = null, $mail_from = null) { | |
if(empty($title)) { | |
$title = ""; | |
} | |
if(empty($text)) { | |
$text = ""; | |
} | |
//validate addresses | |
if(empty($mail_from)) { | |
if(validateMail($mail_to)) { | |
//send mail with from-address | |
$success = mail((string)$mail_to, (string)$title, (string)$text); | |
} else { | |
$success = 0; | |
} | |
} else { | |
if(validateMail($mail_to) && validateMail($mail_from)) { | |
//send mail without from-address | |
$success = mail((string)$mail_to, (string)$title, (string)$text, "From: ".(string)$mail_from); | |
} else { | |
$success = 0; | |
} | |
} | |
return $success; | |
} | |
function validateMail($mail) { | |
if(filter_var($mail, FILTER_VALIDATE_EMAIL) === false) { | |
return 0; | |
} else { | |
return 1; | |
} | |
} | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>EasyMail - Testumgebung</title> | |
<?php include("easymail.php"); ?> | |
</head> | |
<body> | |
<?php sendMail("richartkeil@gmail.com", "Test", "This is a test-message!", "horst123@quark.net"); ?> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment