Exim이 항상 AUTH LOGIN 사용자 이름/비밀번호를 보내지는 않습니다.

Exim이 항상 AUTH LOGIN 사용자 이름/비밀번호를 보내지는 않습니다.

exim(WHM을 통해 구성됨)을 사용하여 메일을 보내고 있습니다. 동일한 구성을 사용하면 대부분의 경우 exim이 올바른 AUTH LOGIN 사용자 이름과 비밀번호를 전송하지만 때로는 이 부분을 생략하고 sendgrid가 다음 오류로 인해 거부하는 경우도 있습니다.

host smtp.sendgrid.net [158.85.10.138]
SMTP error from remote mail server after MAIL FROM:<info@*******.net> SIZE=2048:
550 Unauthenticated senders not allowed

이를 자세히 살펴보면 다음과 같이 문제를 재현할 수 있습니다(매번은 아니지만 때로는).

# exim -v **@****.com
From: **@****.com
To: **@****.com
Subject: Test exim

This is an exim test.

exex 구성 설정은 다음과 같습니다.

섹션: 인증

sendgrid_login:
  driver = plaintext
  public_name = LOGIN
  client_send = : ******** : **************

섹션: 라우터스타트

send_via_sendgrid:
  driver = manualroute
  domains = ! +local_domains
  transport = sendgrid_smtp
  route_list = "* smtp.sendgrid.net::587 byname"
  host_find_failed = defer
  no_more

섹션: 운송 시작

sendgrid_smtp:
  driver = smtp
  hosts = smtp.sendgrid.net
  hosts_require_auth = smtp.sendgrid.net
  hosts_require_tls = smtp.sendgrid.net
  authenticated_sender_force = true

작동할 때의 로그는 다음과 같습니다.

LOG: MAIN
  cwd=/home/** 3 args: exim -v **@****.com
From: **@****.com
To: **@****.com
Subject: Test exim

This is an exim test.
LOG: MAIN
  <= **@****-**.com U=jf P=local S=354 T="Test exim"
**@****-** [~]# LOG: MAIN
  cwd=/var/spool/exim 4 args: /usr/sbin/exim -v -Mc 1ZjWZy-0005re-S3
delivering 1ZjWZy-0005re-S3
Transport port=25 replaced by host-specific port=587
Connecting to smtp.sendgrid.net [198.37.144.212]:587 ... connected
  SMTP<< 220 ismtpd-064 ESMTP service ready
  SMTP>> EHLO **.****-**.com
  SMTP<< 250-**.***.26.157
         250-SIZE 20480000
         250-STARTTLS
         250-AUTH PLAIN LOGIN
         250-8BITMIME
         250-PIPELINING
         250 AUTH=PLAIN LOGIN
  SMTP>> STARTTLS
  SMTP<< 220 Begin TLS negotiation now
  SMTP>> EHLO **.****-**.com
  SMTP<< 250-**.***.26.157
         250-8BITMIME
         250-SIZE 20480000
         250-AUTH=PLAIN LOGIN
         250-AUTH PLAIN LOGIN
         250 PIPELINING
  SMTP>> AUTH LOGIN
  SMTP<< 334 VXNlcm5hbWU6
  SMTP>> ****
  SMTP<< 334 UGFzc3dvcmQ6
  SMTP>> ********************
  SMTP<< 235 Authentication successful.
  SMTP>> MAIL FROM:<**@****-**.com> SIZE=1388 AUTH=**@****-**.com
  SMTP>> RCPT TO:<**@****.com>
  SMTP>> DATA
  SMTP<< 250 Sender address accepted
  SMTP<< 250 Recipient address accepted
  SMTP<< 354 Continue
  SMTP>> writing message and terminating "."
  SMTP<< 250 Delivery in progress
  SMTP>> QUIT
LOG: MAIN
  => **@****.com R=send_via_sendgrid T=sendgrid_smtp H=smtp.sendgrid.net [198.37.144.212] X=TLSv1.2:AES128-GCM-SHA256:128 A=sendgrid_login C="250 Delivery in progress"
LOG: MAIN
  Completed

라인 SMTP>> AUTH LOGIN과 라인에서 끝나는 바로 아래의 6개 라인에 특별한 주의를 기울이십시오 235 Authentication successful..

다음은 실패입니다.

LOG: MAIN
  cwd=/home/** 3 args: exim -v **@****.com
From: **@****.com
To: **@****.com
Subject: Test exim

This is an exim test.
LOG: MAIN
  <= **@****-**.com U=jf P=local S=340 T="Test exim"
**@****-** [~]# LOG: MAIN
  cwd=/var/spool/exim 4 args: /usr/sbin/exim -v -Mc 1ZjWjO-0006T8-Eq
delivering 1ZjWjO-0006T8-Eq
Transport port=25 replaced by host-specific port=587
Connecting to smtp.sendgrid.net [198.37.144.225]:587 ... connected
  SMTP<< 220 ismtpd-078 ESMTP service ready
  SMTP>> EHLO ****-**.com
  SMTP<< 250-**.***.157
         250-SIZE 20480000
         250-STARTTLS
         250-AUTH PLAIN LOGIN
         250-8BITMIME
         250-PIPELINING
         250 AUTH=PLAIN LOGIN
  SMTP>> STARTTLS
  SMTP<< 220 Begin TLS negotiation now
  SMTP>> EHLO ****-**.com
  SMTP<< 250-**.***.26.157
         250-8BITMIME
         250-SIZE 20480000
         250-AUTH=PLAIN LOGIN
         250-AUTH PLAIN LOGIN
         250 PIPELINING
  SMTP>> MAIL FROM:<**@****-**.com> SIZE=1374
  SMTP>> RCPT TO:<**@****.com>
  SMTP>> DATA
  SMTP<< 550 Cannot receive from specified address <**@****-**.com>: Unauthenticated senders not allowed
  SMTP<< 503 Must have sender before recipient
  SMTP<< 503 Must have valid receiver and originator
  SMTP>> QUIT
LOG: MAIN
  ** **@****.com R=send_via_sendgrid T=sendgrid_smtp H=smtp.sendgrid.net [198.37.144.225] X=TLSv1.2:AES128-GCM-SHA256:128: SMTP error from remote mail server after MAIL FROM:<**@****-**.com> SIZE=1374: 550 Cannot receive from specified address <**@****-**.com>: Unauthenticated senders not allowed
LOG: MAIN
  cwd=/var/spool/exim 8 args: /usr/sbin/exim -v -t -oem -oi -f <> -E1ZjWjO-0006T8-Eq
LOG: MAIN
  <= <> R=1ZjWjO-0006T8-Eq U=mailnull P=local S=1383 T="Mail delivery failed: returning message to sender"
LOG: MAIN
  cwd=/var/spool/exim 4 args: /usr/sbin/exim -v -Mc 1ZjWjn-0006TR-BX
delivering 1ZjWjn-0006TR-BX
LOG: MAIN
  Completed
LOG: MAIN
  => ** <**@****-**.com> R=localuser T=local_delivery
LOG: MAIN
  Completed

SMTP>> AUTH LOGIN다음 6줄은 호출되지 않습니다... ?

문제는 exim이 SMTP>> AUTH LOGIN요청의 실제 부분을 생략하는 이유가 무엇인지인데, 가끔씩만 그럴까요? 을 사용하고 있습니다.똑같아연결 구성(두 로그 모두에서 로 참조되는 것을 볼 수 있음 R=send_via_sendgrid T=sendgrid_smtp)

답변1

2015년 11월 8일 수정:

해결책은 다음과 같습니다.

hosts_require_auth = <; $host_address
hosts_require_tls = <; $host_address

대신에

hosts_require_auth = smtp.sendgrid.net
hosts_require_tls = smtp.sendgrid.net

이상하게 보이는 <;구문은 호스트 이름이 IPv6 주소로 확인되는 경우입니다(IPv6 주소의 콜론이 다르게 들리는 것처럼 들리기 때문에). $host_address 변수는 호스트 이름이 확인하는 IP 주소가 변경되는 경우(예: smtp.sendgrid.net이 여러 IP로 확인되고 때로는 다른 IP가 중간 프로세스로 확인되는 경우)를 해결하는 데 사용됩니다. 다시 조회할 필요가 없다고 생각합니다(또한smtp 전송). 신용 거래Gmail을 스마트호스트로 사용하도록 Exim 구성그리고 OP와 @wurtel도 있습니다.

이전 답변 / 테스트 및 재현 방법::

IP 주소 변경에 대한 질문에 대한 @wurtel의 의견이 옳다고 생각합니다. smtp.sendgrid.net이 해결하는 IP를 빠르게 변경하는 스크립트를 사용하여 이를 안정적으로 재현할 수 있기 때문입니다. 또한 호스트 파일에 아무 항목도 입력하지 않으면 5초마다 이메일을 보낼 때 최소 2시간마다 이런 문제가 발생하는 것을 확인했는데 IP를 /etc/hosts에 하드 코딩하면 8시간 동안 지속되었습니다. 해당 전송 빈도에서는 오류가 발생하지 않으므로 이것이 현재 제가 사용하고 있는 임시 해결 방법입니다.

이 문제를 재현한 방법은 다음과 같습니다. 참고: 이는 2015년 10월 말 현재 기준입니다. 그 이후에 시도하는 경우 IP가 다를 수 있으므로 dig smtp.sendgrid.net두 개의 IP를 실행하고 사용하면 대신 반환됩니다.

이것을 /etc/hosts에 추가하세요

108.168.190.108 smtp.sendgrid.net

이것을 PHP 파일에 저장하고 교체하십시오.[이메일 보호됨]귀하가 관리하는 이메일 주소로.

#!/usr/local/bin/php
<?php
while (true) {
    mail('[email protected]', 'Test email deletethiswithafilter', 'test ' . time());
    usleep(500000);
}

이것을 PHP 파일에 저장하고 위의 내용이 실행되는 동안 실행하십시오. 5ms - 15ms마다 smtp.sendgrid.net에 대한 호스트 파일의 항목을 확인하는 두 IP(158.85.10.138 및 108.168.190.108) 사이에서 전환합니다.

#!/usr/local/bin/php
<?php
while (true) {
    passthru('new_hosts_file_contents=`cat /etc/hosts | sed \'s/108.168.190.108/ip108/g\' | sed \'s/158.85.10.138/ip158/g\' | sed \'s/ip108/158.85.10.138/g\' | sed \'s/ip158/108.168.190.108/g\'`; echo "$new_hosts_file_contents" > /etc/hosts 2>&1');
    usleep(10000 + rand(-5000,5000));
}

관련 정보