-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhandle_form.php
36 lines (32 loc) · 1.34 KB
/
handle_form.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?php
require_once("PHPMailer_v5.1/class.phpmailer.php"); // *** This should be the correct path to the phpmailer module ***
define('GUSER', '[email protected]'); // GMail username (without <>)
define('GPWD', 'justapassword'); // GMail password (without <>)
function smtpmailer($to, $from, $from_name, $subject, $body) {
global $error;
$mail = new PHPMailer(); // create a new object
$mail->IsSMTP(); // enable SMTP
$mail->SMTPDebug = 1; // debugging: 1 = errors and messages, 2 = messages only
$mail->SMTPAuth = true; // authentication enabled
$mail->SMTPSecure = 'ssl'; // secure transfer enabled REQUIRED for GMail
$mail->Host = 'smtp.gmail.com'; // Google mailserver address
$mail->Port = 465; // Google mailserver network port
$mail->Username = GUSER;
$mail->Password = GPWD;
$mail->SetFrom($from, $from_name);
$mail->Subject = $subject;
$mail->Body = $body;
$mail->AddAddress($to);
if(!$mail->Send())
{
echo "Error: " . $mail->ErrorInfo;;
}
else
{
echo "Mail sent.";
}
}
$message=$_POST['name'].' with the email address '.$_POST['email'].' has the following comments: '.$_POST['comments'];
// The statement below makes a call to the smtpmailer function with mail parameters (without <>).
smtpmailer('[email protected]', '[email protected]', 'Feedback', 'From the website contact form', $message);
?>