-
Notifications
You must be signed in to change notification settings - Fork 8
/
service.php
65 lines (53 loc) · 2.61 KB
/
service.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
65
<?php
// Import PHPMailer classes into the global namespace
// These must be at the top of your script, not inside a function
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
// Load Composer's autoloader
require 'vendor/autoload.php';
if (isset($_GET['feedback'])) {
$path = 'Cinema/feedback.txt';
$info = $_SERVER["QUERY_STRING"];
$info = substr($info, 0, 200);
$opt = ['产品问题', '播放不了', '信息错误', '其他问题'];
$body = '<div><b>类型:</b>' . $opt[$_GET['Opt']] . '</div>';
$body .= '<div><b>留言:</b>' . $_GET['Msg'] . '</div>';
$body .= '<div><b>联系方式:</b>' . $_GET['Num'] . '</div>';
$body .= '<div><b>链接:</b><a href="' . $_GET['Link'] . '">' . $_GET['Link'] . '</a></div>';
$config = file_get_contents('config.json');
$config = json_decode($config, true);
if ($config['email']['inform']) {
$res = send('收到新的反馈消息', $body, $config['email']);
}
$info .= $res ? '&Send=OK' : '&Send=Fail';
echo file_put_contents($path, $info . "\n", FILE_APPEND) ? 1 : 0;
} else {
echo 'Video-Spider Service!';
}
function send($subject, $body, $config)
{
// Instantiation and passing `true` enables exceptions
$mail = new PHPMailer(true);
$mail->CharSet = $mail::CHARSET_UTF8;
try {
//Server settings
//$mail->SMTPDebug = SMTP::DEBUG_SERVER; // Enable verbose debug output
$mail->isSMTP(); // Send using SMTP
$mail->Host = $config['smtp-Host']; // Set the SMTP server to send through
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = $config['smtp-Username']; // SMTP username
$mail->Password = $config['smtp-Password']; // SMTP password
$mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS; // Enable TLS encryption; `PHPMailer::ENCRYPTION_SMTPS` encouraged
$mail->Port = $config['smtp-Port']; // TCP port to connect to, use 465 for `PHPMailer::ENCRYPTION_SMTPS` above
//Recipients
$mail->setFrom('479846095@qq.com', '影视爬虫');
$mail->addAddress('lifankohome@163.com'); // Add a recipient
// Content
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = $subject;
$mail->Body = $body;
return $mail->send();
} catch (Exception $e) {
return false;
}
}