2021. 10. 22. 18:01ㆍ웹 서버 구축
1. ubuntu 20.04 에 libphp-phpmailer 설치하기
How to install libphp-phpmailer on Ubuntu 20.04 (Focal Fossa)?
Quick installation of libphp-phpmailer Architecture: all Version: 6.0.6-0.1: Step 1: Update system: sudo apt-get update Step 2: Install: libphp-phpmailer Architecture: all Version: 6.0.6-0.1 Ater updaing the OS run following command to install the packae:
www.devmanuals.net
>> 설치된 위치 확인
dpkg -L libphp-phpmailer
>> 해당 소스 코드 확인하기
>> 네임스페이스를 정의해 놓은 것을 확인할 수 있다. 코드를 사용할 때
use PHPMailer\PHPMailer\className
를 사용해야 한다는 것을 알 수 있다.
2. libphp-phpmailer 사용하기
https://github.com/PHPMailer/PHPMailer
GitHub - PHPMailer/PHPMailer: The classic email sending library for PHP
The classic email sending library for PHP. Contribute to PHPMailer/PHPMailer development by creating an account on GitHub.
github.com
(1) 'debug output'이므로 실제 환경에서는 주석 처리해둔다.
$mail->SMTPDebug = SMTP::DEBUG_SERVER; //Enable verbose debug output
↓ 아래 내용 참고 자료
https://nowonbun.tistory.com/612
[PHP] PHPMailer 라이브러리를 이용해서 메일 발송하는 방법
안녕하세요. 명월입니다. 이 글은 PHP에서 PHPMailer 라이브러리를 이용해서 메일 발송하는 방법에 대한 글입니다. 예전에 Java와 C#언어에 대해서도 메일 보내는 방법에 대해 소개한 적이 있습니다.
nowonbun.tistory.com
(2) PHPMailer::ENCRYPTION_SMTPS는 존재하지 않으므로
$mail->SMTPSecure = PHPMailer::ENCRYPTION_SMTPS; //Enable implicit TLS encryption
아래와 같이 코드를 수정한다.
$mail->SMTPSecure = "ssl";
(3) 인코딩 설정
한글로 설정한 제목이 깨져서 원인을 찾아보니 인코딩을 설정하지 않아서 였다.
$mail->CharSet = 'utf-8';
$mail->Encoding = "base64";
위와 같이 수정하면 잘 보내진다.
https://help.naver.com/support/contents/contents.help?serviceNo=2342&categoryNo=2288
네이버 고객센터
IMAP / SMTP 설정 및 해제 방법
help.naver.com
'웹 서버 구축' 카테고리의 다른 글
우분투 용량 부족 문제 해결 (0) | 2021.10.27 |
---|---|
XML 변환기 오류: 요소 없음 해결 (0) | 2021.10.24 |
암호 생성 / MariaDB 계정 비밀번호 변경하기 (0) | 2021.10.20 |
php.ini 업로드 용량 설정 (0) | 2021.10.08 |
폼 전송후 뒤로가기를 막는 방법 (0) | 2021.10.07 |