작업실

우분투에서 구글 SMTP 메일서버 설치 후 에러 해결 방법입니다.

컨텐츠 정보

본문

1. 구글 아이디와 비번을 제대로 넣었는데 계정 인증이 안되어 메일 발송이 안될 경우


https://webdir.tistory.com/227 


위 링크와 같이 셋팅을 했는데 아이디 비번이 안맞아서 메일 발송이 안될 수도 있습니다.


구글은 로그인 인증 보안을 위해 2단계 인증을 하는 경우가 많은데요.


postfix에서는 2단계 인증이 불가능하기 때문에 작동하지 않을 수 있습니다.


그런 경우 앱 비번을 만들어서 16자리 비번을 생성 후 비번을 교체해주면 잘 작동 됩니다.


https://devanswers.co/create-application-specific-password-gmail/ 


위 링크에서 상세히 나와있습니다.


참조하시면 될 듯 합니다.






2. 내부 IP주소(공유기)가 거절되었을 경우


/var/log/mail.log 에서


​May 16 10:33:59 woosungserver postfix/smtpd[166020]: warning: hostname RT-AC68R-8E18 does not resolve to address 192.168.1.1

May 16 10:33:59 woosungserver postfix/smtpd[166020]: connect from unknown[192.168.1.1]

May 16 10:33:59 woosungserver postfix/smtpd[166020]: Anonymous TLS connection established from unknown[192.168.1.1]: TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256

May 16 10:34:00 woosungserver postfix/smtpd[166020]: NOQUEUE: reject: RCPT from unknown[192.168.1.1]: 554 5.7.1 <XXXX@gmail.com>: Relay access denied; from=<solut2000@gmail.com> to=<XXXX@gmail.com> proto=ESMTP helo=<www.wsgvet.com>

May 16 10:34:00 woosungserver postfix/smtpd[166020]: disconnect from unknown[192.168.1.1] ehlo=2 starttls=1 mail=1 rcpt=0/1 quit=1 commands=5/6


위와 같이 192.168.1.1(공유기 대표주소) 이 거절되는 경우


nano /etc/postfix/main.cf

위와 같이 설정에 들어가서


smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated reject_unauth_destination


위와 같이 퍼밋 마이네트웍스를 허용했을 경우


mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128 192.168.1.1


위와 같이 마지막에 192.168.1.1 을 띄어쓰기로 추가해줍니다.


그리고


service postfix restart


3. 인증서를 렛츠인크립트로 교환했을 때 CN 미스매치일때


/var/log/nginx/error.log 에서


[error] 95735#95735: *389469 FastCGI sent in stderr: "PHP message: PHP Warning:  stream_socket_enable_crypto(): Peer certificate CN=`wsgvet.com' did not match expected CN=`127.0.0.1' in /plugin/PHPMailer/class.smtp.php on line 368" while reading response header from upstream, client: 192.168.1.1, server: www.wsgvet.com, request: "POST /adm/sendmail_test.php HTTP/2.0"

위와 같이 


CN이 매칭이 되지 않은 경우 그누보드 config.php에서


대충 157번째 줄에서


// SMTP

// lib/mailer.lib.php 에서 사용

//define('G5_SMTP',      '127.0.0.1');

define('G5_SMTP',      'wsgvet.com');

define('G5_SMTP_PORT', '25');

위와 같이 CN 값을 해당 인증서의 CN값과 매칭을 시켜주면 됩니다.




4. 포트가 막혔을 때


devcot 등 기타 프로그램을 설치하였는데, 그때 25번 포트를 열어놨다가 닫으니 안되더라구요.


다시 열어보니 잘 됩니다.


ufw 및 포트포워딩


모두 열어줘야 되네요.



혹시나  postfix 만 설치시에는 문제가 없을 수도 있으니 굳이 안열어도 될 것 같습니다.

관련자료

  • 서명
    우성짱의 NAS를 운영하고 있습니다.

    저의 즐거움이 여러분의 즐거움이면 좋겠습니다.

댓글 0
등록된 댓글이 없습니다.
전체 157 / 5 페이지
RSS

최근글


새댓글


알림 0