Files
think-greaterchiangmai/think-backend.greaterchiangmai.com/app/Http/Controllers/Helpers/EmailPhpHelperController.php
2025-11-11 14:55:29 +07:00

141 lines
3.6 KiB
PHP

<?php
namespace App\Http\Controllers\Helpers;
use App\Http\DataAccess\UserDataAccess;
use Illuminate\Routing\Controller;
class EmailPhpHelperController extends Controller
{
public function __construct()
{
}
public function sendEmailContact($name, $phone, $email, $comment)
{
$mailSender = env('MAIL_SENDER');
$mailReceiver = env('MAIL_RECEIVER');
// subject
$subject = 'Contact: The Greater Chiangmai : Has Sent You a Message! No reply This email';
// message
$message = '
<!DOCTYPE html>
<html>
<head>
<title> The Greater Chiangmai.com </title>
</head>
<body>
<h3>Hi, ' . 'The Greater Chiangmai' . ' ,</h3>
<p> You have new contact from Contact page, please see the detail below:</p>
<p> Name: ' . $name . ' </p>
<p> Phone: ' . $phone . '</p>
<p> อีเมล: ' . $email . '</p>
<p> ข้อความ: ' . $comment . '</p>
<br/>
<br/>
<p>Thanks,</p>
<p><a href="https://www.The Greater Chiangmai.com/">The Greater Chiangmai</a></p>
</body>
</html>
';
// To send HTML mail, the Content-type header must be set
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-Type: text/html; charset=utf-8' . "\r\n";
// Additional headers
$headers .= 'From:' . $mailSender . "\r\n";
$headers .= "Reply-To:" . $mailSender . "\r\n";
$headers .= "Return-Path:" . $mailSender . "\r\n";
// Mail it
mail($mailReceiver, $subject, $message, $headers);
}
public function sendEmailForgotPassword($emailTo, $token)
{
$mailSender = env('MAIL_SENDER');
// subject
$subject = 'Forgot Password: The Greater Chiangmai : Has Sent You a Message! No reply This email';
$link = url('reset-password/' . $token);
// message
$message = '
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<h3>สวัสดี, ' . $emailTo . ' ,</h3>
<p>เราได้รับคำขอให้รีเซ็ตรหัสผ่านสำหรับบัญชีของคุณ: ' . $emailTo . '</p>
<p><a href="' . $link . '">' . $link . '</a> </p>
<br/>
<p>Thanks,</p>
<br/>
<p><a href="https://www.The Greater Chiangmai.com/">Thai Tourism Volunteers</a></p>
</body>
</html>
';
// To send HTML mail, the Content-type header must be set
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-Type: text/html; charset=utf-8' . "\r\n";
$headers .= 'From:' . $mailSender . "\r\n";
// Mail it
mail($emailTo, $subject, $message, $headers);
}
public function sendEmailResetPassword($emailTo, $newPassword)
{
$mailSender = env('MAIL_SENDER');
// subject
$subject = 'Reset Password: The Greater Chiangmai : Has Sent You a Message! No reply This email';
// message
$message = '
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<h3>สวัสดี, ' . $emailTo . ' ,</h3>
<p>คุณรีเซ็ตรหัสผ่านสำเร็จแล้ว</p>
<p>รหัสผ่านใหม่ของคุณคือ: ' . $newPassword . '</p>
<br/>
<p>Thanks,</p>
<p><a href="https://www.The Greater Chiangmaimanmanmanman.com/">The Greater Chiangmai</a></p>
</body>
</html>
';
// To send HTML mail, the Content-type header must be set
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-Type: text/html; charset=utf-8' . "\r\n";
// Additional headers
$headers .= 'From:' . $mailSender . "\r\n";
// Mail it
mail($emailTo, $subject, $message, $headers);
}
}