웹마스터 팁
php 5.6에서 인증메일 SMTP 연결에 실패할때..
2015.03.31 01:59
서버를 PHP5.6으로 교체했는데 메일이 작동안하더군요..
smtp connect() failed라는 에러가 뜰때 대처방법을 기록차원으로 남겨둡니다.
우선 phpmailer를 최신버전으로 받습니다. (
)
class.smtp.php를 smtp.php로 class.phpmailer.php를 phpmailer.php로 바꾸고
./libs/phpmailer에 smtp.php와 phpmailer.php에 덮어쓰기 해줍니다. (만일을 대비해 백업해주세요)
phpmailer.php에서 클래스 시작전에 require_once 'smtp.php';를 입력해주세요.
29 30 31 32 33 34 | require_once 'smtp.php' ; class PHPMailer { /** * The PHPMailer Version number. |
1285번째줄 근처에 smtpConnect 함수 시작부분에
$options = array_merge(array('ssl' => array('verify_peer' => false, 'verify_peer_name' => false)),$options);
를 입력해주세요.
1285 1286 1287 1288 1289 | public function smtpConnect( $options = array ()) { $options = array_merge ( array ( 'ssl' => array ( 'verify_peer' => false, 'verify_peer_name' => false)), $options ); if ( is_null ( $this ->smtp)) { |
./classes/mail/mail.class.php를 열어 152번째줄 useGmailAccount 함수에서
$this->SMTPSecure = "ssl";
$this->Port = '465';
수정해줍시다.
152 153 154 155 156 157 | function useGmailAccount( $account_name , $account_passwd ) { $this ->SMTPAuth = TRUE; $this ->SMTPSecure = "ssl" ; $this ->Host = 'smtp.gmail.com' ; $this ->Port = '465' ; |
openSSL에 문제가 있어 작동하지 않은듯 합니다..
인증메일을 보내려면 ./classes/mail/mail.class.php 140번째줄 Mail() 함수에
$this->useGmailAccount("아이디", "이메일"); 를 추가해주셔야합니다.
140 141 142 143 | function Mail() { $this ->useGmailAccount( "아이디" , "암호" ); } |
수정파일 올려둡니다. mail.zip