Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function sendMail()
- {
- $comment = null;
- $to = "destination@mail.com";
- $copy = "mymail@mail.com";
- $subject = "Email..";
- if (isset($_POST["contactSubscribe"]) || isset($_POST["questionSubmit"]) || isset($_POST["submit"])) {
- foreach ($_POST as $field => $value) {
- if ($field == "contactName") {
- $contactName = $value;
- }
- if ($field == "email") {
- $email = filter_var($_POST['email'], FILTER_SANITIZE_EMAIL);
- }
- if ($field == "comment") {
- $comment = $value;
- }
- }
- }
- checkConditions();
- mail($to, $subject, $message);
- mail($copy, $subject, $message);
- }
- function checkConditions()
- {
- if ( condition1() ) $message = "Name: $contactName Email: $email";
- if ( condition2() ) && is_null($contactName)) $message = "inputname=i_" . $email;
- if ( condition3() ) && !is_null($comment) ) $message = "Name: $contactName Email: $email Message: $comment";
- }
- function condition1()
- {
- return !is_null($contactName) && is_null($comment);
- }
- function condition2()
- {
- return is_null($comment) && is_null($contactName);
- }
- function condition3()
- {
- return !is_null($contactName) && !is_null($comment);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement