Sunday, August 19, 2007

SMTP command

note ไว้หน่อยกันลืม

220 mail.domain.ext ESMTP Sendmail ?version-number?; ?date+time+gmtoffset?
HELO local.domain.name
250 mail.domain.ext Hello local.domain.name [loc.al.i.p], pleased to meet you
MAIL FROM: mail@domain.ext
250 2.1.0 mail@domain.ext... Sender ok
RCPT TO: mail@otherdomain.ext
250 2.1.0 mail@otherdomain.ext... Recipient ok
DATA
354 go ahead
From: John <@domain.ext>
To: Nobody
Subject:-type subject here-

hello message here
.
250 2.0.0 ???????? Message accepted for delivery
QUIT
221 2.0.0 mail.domain.ext closing connection

ถ้าต้อง AUTH ก็จะนำ username กับ password มา encode ด้วย base64 ก่อนคือ
base64.encodestring('\000user@domain.ext\000password')
ได้เป็น 'AHVzZXJAZG9tYWluLmV4dABwYXNzd29yZA=='

แล้วทำ AUTH หลัง HELO หรือ EHLO
AUTH PLAIN
AHVzZXJAZG9tYWluLmV4dABwYXNzd29yZA==
235 ok, go ahead

reponse จาก server สำคัญที่ตัวเลข code อันแรก 200 กว่าคือพวก OK

No comments:

Post a Comment