Amazon ec2 서버에 SES 서버를 설치하고 이메일과 SMTP를 확인했습니다. 문의 양식을 통해 이메일을 보내고 싶습니다. PHP 코드 양식 amazon을 얻었습니다. var / www / html 폴더에 PHPMailer를 설치 하고 PHPMailer 클래스를 다른 PHP 파일이라고 부릅니다. 저는 validate 폴더 안에있는 다른 파일을 호출했습니다 . 코드 세부 정보가 누락 된 부분을 이해할 수 없습니다. 첨부 된 이미지 내가 실수 한 부분을 확인하고 알려 주시고 이러한 문제를 해결하도록 도와주세요.
<?php
//Import the PHPMailer class into the global namespace
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\SMTP;
//SMTP needs accurate times, and the PHP time zone MUST be set
//This should be done in your php.ini, but this is how to do it if you don't have access to that
date_default_timezone_set('Etc/UTC');
require '../vendor/autoload.php';
//Create a new PHPMailer instance
$mail = new PHPMailer;
//Tell PHPMailer to use SMTP
$mail->isSMTP();
//Enable SMTP debugging
// SMTP::DEBUG_OFF = off (for production use)
// SMTP::DEBUG_CLIENT = client messages
// SMTP::DEBUG_SERVER = client and server messages
$mail->SMTPDebug = SMTP::DEBUG_SERVER;
//Set the hostname of the mail server
$mail->Host = 'email-smtp.us-east-1.amazonaws.com';
//Set the SMTP port number - likely to be 25, 465 or 587
$mail->Port = 25;
//Whether to use SMTP authentication
$mail->SMTPAuth = true;
//Username to use for SMTP authentication
$mail->Username = 'AKIA4I2MVSMJS34XXXX';
//Password to use for SMTP authentication
$mail->Password = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
//Set who the message is to be sent from
$mail->setFrom('[email protected]', 'Jerad');
//Set an alternative reply-to address
$mail->addReplyTo('[email protected]', 'Arul');
//Set who the message is to be sent to
$mail->addAddress('[email protected]', 'John Doe');
//Set the subject line
$mail->Subject = 'PHPMailer SMTP test';
//Read an HTML message body from an external file, convert referenced images to embedded,
//convert HTML into a basic plain-text alternative body
//$mail->msgHTML(file_get_contents('contents.html'), __DIR__);
$mail->Body= 'testing Success';
//Replace the plain text body with one created manually
$mail->AltBody = 'This is a plain-text message body';
//Attach an image file
//$mail->addAttachment('images/phpmailer_mini.png');
//send the message, check for errors
if (!$mail->send()) {
echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
echo 'Message sent!';
}
?>
보내기 버튼을 클릭하면이 메시지가 나타납니다.
PHPMailer 와 PHP PEAR 메일 링 클래스를 혼동하고 있습니다. 현재 둘 다 사용하려고합니다.
PHPMailer SMTP 자습서 를 사용하여 PEAR 클래스 대신 메일을 보내십시오.
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다