Add: PHPMailer to naver email
This commit is contained in:
@@ -0,0 +1,62 @@
|
||||
<?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';
|
||||
|
||||
function send_naver_mail($maestro_email, $maestro_name, $subject, $body) {
|
||||
global $new_line; // = "\r\n";
|
||||
global $html_br_tag; // = "<br/>";
|
||||
|
||||
// global $from; // = "support+chocomae@jinaju.com";
|
||||
// global $bcc; // = "support+chocomae.automail@jinaju.com";
|
||||
|
||||
// mail sender info
|
||||
global $sender_name; // = "초코마에";
|
||||
$sender_email = "jisangs@naver.com"; // = $from;
|
||||
global $sender_address; // = $from;
|
||||
global $sender_bcc; // = $bcc;
|
||||
|
||||
$mail = new PHPMailer(true);
|
||||
|
||||
try {
|
||||
//Server settings
|
||||
// $mail->SMTPDebug = SMTP::DEBUG_SERVER; //Enable verbose debug output
|
||||
$mail->isSMTP(); // Send using SMTP
|
||||
$mail->Host = 'smtp.naver.com'; // Set the SMTP server to send through
|
||||
$mail->SMTPAuth = true; // Enable SMTP authentication
|
||||
$mail->Username = 'chocomae@jinaju.com'; // SMTP username
|
||||
$mail->Password = 'n52napark!'; // 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($maestro_email, $maestro_name); // Add a recipient
|
||||
$mail->addReplyTo($sender_address, $sender_name);
|
||||
$mail->addBCC($sender_bcc);
|
||||
|
||||
// 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