/var/www/hkosl.com/securexpert/contact_process.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?php
error_reporting
(0);
ini_set('display_errors'0);
require_once 
__DIR__ '/vendor/dapphp/securimage/securimage.php';
require_once 
__DIR__ '/vendor/phpmailer/phpmailer/PHPMailerAutoload.php';

$image = new Securimage();
if (
$image->check($_POST['captcha_code']) == true) {
//    echo "Correct!";

    
$mail = new PHPMailer(true);                              // Passing `true` enables exceptions
    
try {
        
$x_mail = new PHPMailer();
        
//Server settings
//        $mail->SMTPDebug = 2;                                 // Enable verbose debug output
//        $mail->isSMTP();                                      // Set mailer to use SMTP
        
$mail->Host 'localhost';  // Specify main and backup SMTP servers
//        $mail->SMTPAuth = true;                               // Enable SMTP authentication
//        $mail->Username = '5dad06ab71a26f';                   // SMTP username
//        $mail->Password = '9c7615563f25fe';                   // SMTP password
//        $mail->SMTPSecure = 'tls';                            // Enable TLS encryption, `ssl` also accepted
//        $mail->Port = 465;                                    // TCP port to connect to
        
$mail->CharSet 'UTF-8';

        
//Recipients
        
$mail->setFrom('sales@securexpert.com.hk''');
        
$mail->addAddress('sales@securexpert.com.hk''');     // Add a recipient
//        $mail->addAddress('recipient@example.com');          // Name is optional
//        $mail->addReplyTo('replyto@example.com', 'Information');
//        $mail->addCC('cc@example.com');
//        $mail->addBCC('bcc@example.com');

        //Attachments
//        $mail->addAttachment('/var/tmp/file.tar.gz');         // Add attachments
//        $mail->addAttachment('/tmp/image.jpg', 'new.jpg');    // Optional name

        //Content
        
$mail->isHTML(true);                                  // Set email format to HTML
        
$mail->Subject '剛剛接收到一個來自網站上的查詢';
        
$mail->Body "<p>姓名: ".htmlspecialchars($_POST['name'])."</p>
        <p>電話: "
.htmlspecialchars($_POST['tel'])."</p>
        <p>電子郵件: "
.htmlspecialchars($_POST['email'])."</p>
        <p>留言: "
.nl2br(htmlspecialchars($_POST['content']))."</p>";
        
//        $mail->AltBody = 'This is the body in plain text for non-HTML mail clients';

        
if (!$mail->send()) {
            echo 
"Mailer Error: " $mail->ErrorInfo;
        } else {
            
//echo "Message sent!";
            
header('Location: index.php');

        }
    } catch (
Exception $e) {
        echo 
'Message could not be sent. Mailer Error: '$mail->ErrorInfo;
    }

} else {
    echo 
"Sorry, wrong code.";
}
?>