Add: PHPMailer
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
header("Content-Type: application/json");
|
||||
|
||||
use PHPMailer\PHPMailer\PHPMailer;
|
||||
use PHPMailer\PHPMailer\Exception;
|
||||
|
||||
require './../PHPMailer/src/Exception.php';
|
||||
require './../PHPMailer/src/PHPMailer.php';
|
||||
require './../PHPMailer/src/SMTP.php';
|
||||
|
||||
// Load Composer's autoloader
|
||||
// require $_SERVER['DOCUMENT_ROOT'] . '/vendor/autoload.php';
|
||||
|
||||
$sender_email = 'support@jinaju.com';
|
||||
$sender_name = '초코마에';
|
||||
|
||||
function send_gmail($email, $name, $subject, $body) {
|
||||
global $sender_email;
|
||||
global $sender_name;
|
||||
|
||||
$mail = new PHPMailer(true);
|
||||
|
||||
try {
|
||||
//Server settings
|
||||
// $mail->SMTPDebug = SMTP::DEBUG_SERVER; //Enable verbose debug output
|
||||
$mail->isSMTP(); // Send using SMTP
|
||||
$mail->Host = 'smtp.gmail.com'; // Set the SMTP server to send through
|
||||
$mail->SMTPAuth = true; // Enable SMTP authentication
|
||||
$mail->Username = 'support@jinaju.com'; // SMTP username
|
||||
$mail->Password = '52napark!'; // SMTP password
|
||||
$mail->CharSet = 'utf-8';
|
||||
$mail->Encoding = "base64";
|
||||
$mail->SMTPSecure = PHPMailer::ENCRYPTION_SMTPS; //Enable implicit TLS encryption
|
||||
// $mail->SMTPSecure = 'ssl';
|
||||
$mail->Port = 465; // TCP port to connect to, use 465 for `PHPMailer::ENCRYPTION_SMTPS` above
|
||||
|
||||
|
||||
//Recipients
|
||||
$mail->SetFrom($sender_email, $sender_name);
|
||||
$mail->addAddress($email, $name); // Add a recipient
|
||||
$mail->addReplyTo($sender_email, $sender_name);
|
||||
$mail->addCC($sender_email);
|
||||
|
||||
// Content
|
||||
$mail->isHTML(true); // Set email format to HTML
|
||||
$mail->Subject = $subject;
|
||||
$mail->Body = $body;
|
||||
|
||||
$mail->send();
|
||||
echo 'Message has been sent';
|
||||
return true;
|
||||
} catch (Exception $e) {
|
||||
echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user