Anxhelo Lushka
7 years ago
committed by
GitHub
1 changed files with 53 additions and 56 deletions
@ -1,56 +1,53 @@ |
|||||
-<?php |
<?php |
||||
- |
//Import the PHPMailer class into the global namespace |
||||
-//Import the PHPMailer class into the global namespace |
use PHPMailer\PHPMailer\PHPMailer; |
||||
-use PHPMailer\PHPMailer\PHPMailer; |
require '../vendor/autoload.php'; |
||||
-require '../vendor/autoload.php'; |
|
||||
- |
if (array_key_exists('to', $_POST)) { |
||||
-if (array_key_exists('to', $_POST)) { |
$err = false; |
||||
- $err = false; |
$msg = ''; |
||||
- $msg = ''; |
$email = ''; |
||||
- $email = ''; |
|
||||
- |
//Apply some basic validation and filtering to the subject |
||||
- //Apply some basic validation and filtering to the name |
if (array_key_exists('subject', $_POST)) { |
||||
- if (array_key_exists('name', $_POST)) { |
$subject = substr(strip_tags($_POST['subject']), 0, 255); |
||||
- //Limit length and strip HTML tags |
} else { |
||||
- $name = substr(strip_tags($_POST['name']), 0, 255); |
$subject = 'No subject given'; |
||||
- } else { |
} |
||||
- $name = ''; |
|
||||
- } |
//Apply some basic validation and filtering to the name |
||||
- |
if (array_key_exists('name', $_POST)) { |
||||
- //Apply some basic validation and filtering to the surname |
//Limit length and strip HTML tags |
||||
- if (array_key_exists('surname', $_POST)) { |
$name = substr(strip_tags($_POST['name']), 0, 255); |
||||
- //Limit length and strip HTML tags |
} else { |
||||
- $name = substr(strip_tags($_POST['name']), 0, 255); |
$name = ''; |
||||
- } else { |
} |
||||
- $name = ''; |
|
||||
- } |
//Make sure the address they provided is valid before trying to use it |
||||
- |
if (array_key_exists('email', $_POST) and PHPMailer::validateAddress($_POST['email'])) { |
||||
- //Make sure the address they provided is valid before trying to use it |
$email = $_POST['email']; |
||||
- if (array_key_exists('email', $_POST) and PHPMailer::validateAddress($_POST['email'])) { |
} else { |
||||
- $email = $_POST['email']; |
$msg .= "Error: invalid email address provided"; |
||||
- } else { |
$err = true; |
||||
- $msg .= "Error: invalid email address provided"; |
} |
||||
- $err = true; |
if (!$err) { |
||||
- } |
$mail = new PHPMailer; |
||||
- |
$mail->isSMTP(); |
||||
- if (!$err) { |
$mail->Host = 'localhost'; |
||||
- $mail = new PHPMailer; |
$mail->Port = 2500; |
||||
- $mail->isSMTP(); |
$mail->CharSet = 'utf-8'; |
||||
- $mail->Host = 'localhost'; |
//It's important not to use the submitter's address as the from address as it's forgery, |
||||
- $mail->Port = 2500; |
//which will cause your messages to fail SPF checks. |
||||
- $mail->CharSet = 'utf-8'; |
//Use an address in your own domain as the from address, put the submitter's address in a reply-to |
||||
- //It's important not to use the submitter's address as the from address as it's forgery, |
$mail->setFrom('form@ura.design', (empty($name) ? 'Contact form' : $name)); |
||||
- //which will cause your messages to fail SPF checks. |
$mail->addAddress('anxhelo1995@gmail.com'); |
||||
- //Use an address in your own domain as the from address, put the submitter's address in a reply-to |
$mail->addReplyTo($email, $name); |
||||
- $mail->setFrom('form@ura.design', (empty($name) ? 'Contact form' : $name)); |
$mail->Subject = 'Contact form: ' . $subject; |
||||
- $mail->addAddress('anxhelo1995@gmail.com'); |
$mail->Body = "Contact form submission\n\n" . $message; |
||||
- $mail->addReplyTo($email, $name); |
if (!$mail->send()) { |
||||
- $mail->Subject = 'Contact form: ' . $subject; |
$msg .= "Mailer Error: " . $mail->ErrorInfo; |
||||
- $mail->Body = "Contact form submission\n\n" . $projectname . $message . $budget; |
} else { |
||||
- if (!$mail->send()) { |
$msg .= "Message sent!"; |
||||
- $msg .= "Mailer Error: " . $mail->ErrorInfo; |
} |
||||
- } else { |
} |
||||
- $msg .= "Message sent!"; |
} ?> |
||||
- } |
|
||||
- } |
|
||||
-} ?> |
|
||||
|
Loading…
Reference in new issue