/var/www/hkosl.com/gba-owea/sc/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
61
62
63
64
<?php
//error_reporting(E_ALL);
//ini_set('display_errors', 0);

require_once dirname(__DIR__). '/vendor/dapphp/securimage/securimage.php';
require_once 
dirname(__DIR__). '/vendor/phpmailer/phpmailer/PHPMailerAutoload.php';

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

    
$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 = '';                                   // SMTP username
//        $mail->Password = '';                               // 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('info@gba-owea.com''大灣區傑出女企業家獎');
        
$mail->addAddress('info@gba-owea.com''');     // 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 '剛剛接收到一個來自 '.htmlspecialchars($_POST['contactform-name']).' 大灣區傑出女企業家獎網站上的查詢';
        
$mail->Body "<p>姓名: ".htmlspecialchars($_POST['contactform-name'])."</p>
        <p>電郵: "
.htmlspecialchars($_POST['contactform-email'])."</p>
        <p>電話: "
.htmlspecialchars($_POST['contactform-phone'])."</p>
        <p>主題: "
.htmlspecialchars($_POST['contactform-subject'])."</p>
        <p>内容: "
.nl2br(htmlspecialchars($_POST['contactform-message']))."</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: contactus.php');

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

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