PHP Mail - swkim0128/PARA GitHub Wiki
php email ๋ณด๋ด๋ ๋ฐฉ๋ฒ์ ๋ํ ๋ด์ฉ
php ๋ด์ ํจ์๋ฅผ ์ฌ์ฉํ๋ ๋ฐฉ๋ฒ๊ณผ ๋ผ์ด๋ธ๋ฌ๋ฆฌ PHPMailer๋ฅผ ์ฌ์ฉํ๋ ๋ฐฉ๋ฒ์ด ์๋ค.
PHPMailer์ ๊ฒฝ์ฐ ๋ค๋ฅธ ์ด๋ฉ์ผ smtp ์๋ฒ๋ฅผ ์ฌ์ฉํ์ฌ ๋ฉ์ผ์ ๋ณด๋ด๋ ๋ฐฉ์์ด๋ค.
์ฃผ์
๋ด๋ถ smtp ์๋ฒ๊ฐ ํ์ํ๋ค.
$to = $email; // Send email to our user
$subject = 'Signup | Verification'; // Give the email a subject
$message = '
Thanks for signing up!
Your account has been created, you can login with the following credentials after you have activated your account by pressing the url below.
------------------------
Username: '.$name.'
Password: '.$password.'
------------------------
Please click this link to activate your account:
http://www.yourwebsite.com/verify.php?email='.$email.'&hash='.$hash.'
'; // Our message above including the link
$headers = 'From:[email protected]' . "\r\n"; // Set from headers
mail($to, $subject, $message, $headers); // Send our email
https://github.com/PHPMailer/PHPMailer - release - download
mv project_root / inc /
<?php
require_once $_SERVER['DOCUMENT_ROOT'] . '/inc/PHPMailer/src/PHPMailer.php';
require_once $_SERVER['DOCUMENT_ROOT'] . '/inc/PHPMailer/src/SMTP.php';
require_once $_SERVER['DOCUMENT_ROOT'] . '/inc/PHPMailer/src/Exception.php';
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\SMTP;
use PHPMailer\PHPMailer\Exception;
$mail = new PHPMailer(true);
try {
$mail->isSMTP();
$mail->Host = 'smtp.naver.com';
$mail->SMTPAuth = true;
$mail->Username = 'id';
$mail->Password = '*********';
$mail->CharSet = 'utf-8';
$mail->Encoding = 'base64';
$mail->SMTPSecure = 'ssl';
$mail->Port = 465;
$mail->setFrom('[email protected]', 'danawa');
$mail->addAddress($email);
$mail->isHTML(true);
$mail->Subject = '๋ค๋์ ์ด๋ฉ์ผ ์ธ์ฆ';
$mail->Body = "๋ค๋์ ์ด๋ฉ์ผ ์ธ์ฆ์
๋๋ค.
์๋ ๋งํฌ๋ฅผ ํด๋ฆญํด ์ด๋ฉ์ผ ์ธ์ฆ์ ์งํํ์ธ์.
http://localhost/index.php/auth/verify?email={$email}&hash={$hash}";
$mail->send();
} catch (Exception $ex) {
echo "<script>
alert('{$ex}');
</script>";
}