You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
165 lines
5.6 KiB
165 lines
5.6 KiB
<?php
|
|
/*
|
|
* 諮詢信
|
|
*
|
|
*/
|
|
use PHPMailer\PHPMailer\PHPMailer;
|
|
use PHPMailer\PHPMailer\SMTP;
|
|
use PHPMailer\PHPMailer\Exception;
|
|
require '../../composer/vendor/autoload.php';
|
|
|
|
class SendMail{
|
|
public $receiverMail;
|
|
|
|
function __construct(){
|
|
date_default_timezone_set("Asia/Taipei");
|
|
$this->mail = new PHPMailer;
|
|
$this->receiverMail = 'service@masada.com.tw';
|
|
}
|
|
|
|
/**
|
|
* 取得收件者帳號
|
|
*
|
|
* @param string $mail
|
|
* @return string
|
|
*/
|
|
function getReceiver(){
|
|
return $this->receiverMail;
|
|
}
|
|
|
|
/**
|
|
* 設定收件者帳號
|
|
*
|
|
* @param string $mail
|
|
* @return string
|
|
*/
|
|
function setReceiver($mail){
|
|
$this->receiverMail = $mail;
|
|
}
|
|
|
|
/**
|
|
* 發送信件
|
|
*
|
|
* @param string $sendEmail 發送的 email 帳號
|
|
* @param string $subject 信件主旨
|
|
* @param string $content 信件內容
|
|
* @return string
|
|
*/
|
|
function sendMail($sendEmail = '', $subject = '', $content = ''){
|
|
if ( trim($sendEmail) == '' || trim($subject) == '' || trim($content) == '' ){
|
|
return 'parameters empty';
|
|
}
|
|
$this->mail->IsSMTP();
|
|
$this->mail->SMTPAuth = false;
|
|
$this->mail->SMTPSecure = false;
|
|
$this->mail->SMTPAutoTLS = false;
|
|
$this->mail->Host = "mail.masada.com.tw";
|
|
$this->mail->Port = 25;
|
|
$this->mail->Username = "service@masada.com.tw";
|
|
$this->mail->Password = "@s12345";
|
|
|
|
$this->mail->CharSet = 'UTF-8';
|
|
$this->mail->setFrom('service@masada.com.tw', '永佳捷客服');
|
|
$this->mail->addAddress($sendEmail);
|
|
$this->mail->addAddress('owen@masada.com.tw', '江正文');
|
|
$this->mail->addAddress($sendEmail);
|
|
$this->mail->addAddress('jessiechang@masada.com.tw', '張珈瑄');
|
|
$this->mail->Subject = $subject;
|
|
$this->mail->msgHTML($content, __DIR__);
|
|
$this->mail->AltBody = 'This is a plain-text message body';
|
|
|
|
if (!$this->mail->send()) {
|
|
return $this->mail->ErrorInfo;
|
|
}
|
|
|
|
return 'success';
|
|
|
|
}
|
|
|
|
/**
|
|
* 取得諮詢信表單發送信件內容
|
|
*
|
|
* @param array $formArr 表格填寫的內容
|
|
* @return string
|
|
*/
|
|
function getEstimateMailContent( $formArr){
|
|
$firstName = isset( $formArr['firstname'] ) ? $formArr['firstname'] : '';
|
|
$lastName = isset( $formArr['lastname'] ) ? $formArr['lastname'] : '';
|
|
$gender = isset( $formArr['gender'] ) ? $formArr['gender'] : '';
|
|
$company = isset( $formArr['company'] ) ? $formArr['company'] : '';
|
|
$email = isset( $formArr['email'] ) ? $formArr['email'] : '';
|
|
$tel = isset( $formArr['tel'] ) ? $formArr['tel'] : '';
|
|
// $area = isset( $formArr['area'] ) ? $formArr['area'] : '';
|
|
$job = isset( $formArr['job'] ) ? $formArr['job'] : '';
|
|
$service = isset( $formArr['service'] ) ? $formArr['service'] : '';
|
|
$where = isset( $formArr['where'] ) ? $formArr['where'] : '';
|
|
$textarea = isset( $formArr['textarea'] ) ? $formArr['textarea'] : '';
|
|
|
|
//以下推送到From:即時通知 To:永佳捷經理會議群組
|
|
$access_token = array();
|
|
$access_token[]="C680v3wHFMtdAJ3fxZ6sEr5HyTB4o7Yyc7KdB8C82jU"; #From:即時通知 To:永佳捷經理會議群組
|
|
$TargetCount = count($access_token);
|
|
$Push_Content['message'] = "線上諮詢表單" . "\n";
|
|
$Push_Content['message'] = $Push_Content['message'] . "姓氏: " . $firstName . "\n";
|
|
$Push_Content['message'] = $Push_Content['message'] . "名字: " . $lastName . "\n";
|
|
$Push_Content['message'] = $Push_Content['message'] . "性別: " . $gender . "\n";
|
|
$Push_Content['message'] = $Push_Content['message'] . "公司名稱/社區名稱: " . $company . "\n";
|
|
$Push_Content['message'] = $Push_Content['message'] . "E-mail: " . $email . "\n";
|
|
$Push_Content['message'] = $Push_Content['message'] . "電話: " . $tel . "\n";
|
|
$Push_Content['message'] = $Push_Content['message'] . "職稱: " . $job . "\n";
|
|
$Push_Content['message'] = $Push_Content['message'] . "服務: " . $service . "\n";
|
|
$Push_Content['message'] = $Push_Content['message'] . "在哪裡獲得永佳捷智能電梯的資訊: " . $where . "\n";
|
|
$Push_Content['message'] = $Push_Content['message'] . "留言訊息: " . $textarea;
|
|
#$Push_Content['message'] = $Push_Content['message'] . "發生時間: " . date('Y-m-d H:i:s');
|
|
|
|
for ($i=0;$i<$TargetCount;$i++) {
|
|
$ch = curl_init("https://notify-api.line.me/api/notify");
|
|
curl_setopt($ch, CURLOPT_POST, true);
|
|
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
|
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
|
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
|
|
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
|
|
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($Push_Content));
|
|
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
|
|
'Content-Type: application/x-www-form-urlencoded',
|
|
'Authorization: Bearer '.$access_token[$i]
|
|
));
|
|
$response_json_str = curl_exec($ch);
|
|
curl_close($ch);
|
|
}
|
|
//以上推送到From:即時通知 To:永佳捷經理會議群組
|
|
|
|
|
|
return '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
|
<html>
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
|
<title>Send Excel File</title>
|
|
</head>
|
|
<body>
|
|
<div style="width: 640px; font-family: Arial, Helvetica, sans-serif; font-size: 12px;">
|
|
<div align="center">
|
|
<a></a>
|
|
</div>
|
|
<p> 姓氏:'.$firstName.'</p>
|
|
<p> 名字:'.$lastName.'</p>
|
|
<p> 性別:'.$gender.'</p>
|
|
<p> 公司名稱/社區名稱:'.$company.'</p>
|
|
<p> E-mail:'.$email.'</p>
|
|
<p> 電話:'.$tel.'</p>
|
|
<p> 職稱:'.$job.'</p>
|
|
<p> 服務:'.$service.'</p>
|
|
<p> 在哪裡獲得永佳捷智能電梯的資訊:'.$where.'</p>
|
|
<p> 留言訊息:'.$textarea.'</p>
|
|
|
|
<p> </p>
|
|
<p> *此信件為系統發出信件,請勿直接回覆,感謝您的配合! </p>
|
|
</div>
|
|
</body>
|
|
</html>';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
?>
|