-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsendmail.php
executable file
·50 lines (43 loc) · 2.04 KB
/
sendmail.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
<?php
//$sCharset = 'utf-8';
header("charset=utf-8");
error_reporting(0);
require 'PHPMailerAutoload.php';
$C_name=$_POST['C_name'];
$C_email=$_POST['email'];
$C_tel=$_POST['C_tel'];
$C_message=$_POST['routeList'];
$mail = new PHPMailer;
//$mail->SMTPDebug = 3; // Enable verbose debug output
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'smtp.gmail.com'; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = '[email protected]'; // SMTP username
$mail->Password = '2017longmen'; // SMTP password
//$mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 25; // TCP port to connect to
$mail->setFrom('[email protected]', 'Route');
$mail->addAddress('[email protected]', ''); // Add a recipient
//$mail->addAddress('[email protected]'); // Name is optional
//$mail->addReplyTo('[email protected]', 'Information');
//$mail->addCC('[email protected]');
//$mail->addBCC('[email protected]');
//$mail->addAttachment('/var/tmp/file.tar.gz'); // Add attachments
//$mail->addAttachment('/tmp/image.jpg', 'new.jpg'); // Optional name
$mail->isHTML(true); // Set email format to HTML
//$C_name = iconv('big5',$sCharset, $C_name);
$sSubject = iconv('big5', $sCharset, $sSubject);
$sSubject = "預約路線";
$mail->Body = "預約路線:".$C_message."<br/>姓名:".$C_name."<br />電話:".$C_tel."<br />信箱:".$C_email;
//$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
if(!$mail->send()) {
echo '郵件未被寄出!';
echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
echo '已成功寄出預約路線郵件!';
$url = "http://localhost/database_1/route.php";
echo "<script type='text/javascript'>";
echo "window.location.href='$url'";
echo "</script>";
}
?>