python smtplib 관련 문제..

ha3k1e의 이미지

python의 smtplib를 이용하여 메일 전송을 자동화 하려고합니다.

현재 같은 도메인,

그러니까 smtplib.SMTP("test@example.com",25)로 접속 했을 때, 도메인이 example.com인 것으로는 잘 보내어지는데

naver.com이나 gmail.com 같은 타 도메인으로는 메일이 전송되지 않습니다.

정확히는 메일을 전송했다고 뜨고, 아무런 에러도 나오지 않는데, 메일이 도착하지 않습니다.

저와 같은 이슈를 해결한 글을 찾지 못하겠네요 ㅠㅠ

혹시 이유가 무엇인지 아시나요..

def send_mail(msg):
    smtplib.SMTP('test@example.com",25)
    smtp.starttls()
    smtp.sendmail(_from, _to, msg.as_string())
    smtp.quit()

참고로 login을 안해도 사용할 수 있도록 웹 메일 시스템이 설정되어있고,

수동으로 보낼때는 다른 도메인으로 전송되기때문에 릴레이 문제도 아닙니다.

익명 사용자의 이미지

Python을 잘 알지는 못하지만, 파이썬 문제라기 보다는

exampl.com의 smtpd 서버 설정이 문제 인거처럼 보이네요

먼저 아래처럼 smtpd가 잘 동작 하는지 테스트 해보시고, 파이썬에서 테스트 해보시는게 좋을 듯 합니다.

telnet exampl.com 25 
 
20 smtp.example.com ESMTP Postfix  
C: HELO relay.example.org  
S: 250 Hello relay.example.org, I am glad to meet you  
C: MAIL FROM:<bob@example.org>  
S: 250 Ok  
C: RCPT TO:<alice@example.com>  
S: 250 Ok  
C: RCPT TO:<theboss@example.com>  
S: 250 Ok  
C: DATA  
S: 354 End data with <CR><LF>.<CR><LF>  
C: From: "Bob Example" <bob@example.org>  
C: To: "Alice Example" <alice@example.com>  
C: Cc: <a href="mailto:theboss@example.com" rel="nofollow">theboss@example.com</a>  
C: Date: Tue, 15 Jan 2008 16:02:43 -0500  
C: Subject: Test message  
C:  
C: Hello Alice.  
C: This is a test message with 5 header fields and 4 lines in the message body.  
C: Your friend,  
C: Bob  
C: .  
S: 250 Ok: queued as 12345  
C: QUIT  
S: 221 Bye  
{The server closes the connection}

출처 : http://blog.saltfactory.net/send-mail-via-smtp-and-python/

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.