PHP Mail - swkim0128/PARA GitHub Wiki


type: PHP archive: false

PHP Mail


php email ๋ณด๋‚ด๋Š” ๋ฐฉ๋ฒ•์— ๋Œ€ํ•œ ๋‚ด์šฉ

php ๋‚ด์˜ ํ•จ์ˆ˜๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ๋ฐฉ๋ฒ•๊ณผ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ PHPMailer๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ๋ฐฉ๋ฒ•์ด ์žˆ๋‹ค.

PHPMailer์˜ ๊ฒฝ์šฐ ๋‹ค๋ฅธ ์ด๋ฉ”์ผ smtp ์„œ๋ฒ„๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ๋ฉ”์ผ์„ ๋ณด๋‚ด๋Š” ๋ฐฉ์‹์ด๋‹ค.

PHP mail


์ฃผ์˜ ๋‚ด๋ถ€ 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

PHPMailer


์„ค์น˜

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>";
}
โš ๏ธ **GitHub.com Fallback** โš ๏ธ