开发者

SMTP plain authentication problem using C++

Using MS Visual C++ and Boost asio, I'm trying to add the ability to send email to an application using the SMTP protocol.

The problem arises when I try to authenticate the connection. Here is a snapshot of the situation supposing the attempts to connect to an account in a server of the 1&1 provider, which uses its own server named "nemesis".

(S: server response and C: is the client-command) for test purposes, we assume that try to send a message from the account sender@mysite.com to target@mysite.com

C:    connect with hostname <smtp.1and1.es> and port <587> 
S:    220 smtp.1and1.es (mreu1) Welcome to Nemesis ESMTP server
C:    EHLO mysite.com
S:    250-smtp.1and1.es
S:    250-STARTTLS
S:    250-AUTH LOGIN PLAIN
S:    250-AUTH=LOGIN PLAIN
S:    250-PIPELINING
S:    250-SIZE 120000000
S:    250 HELP
C:    AUTH LOGIN
S:    504 Unknown authentication mechanism

As far as I know, the server offers two authentication modes to the user: LOGIN and PLAIN, and we try to use the former (the most used mode).

Supposedly, from this point, the server should answer with the requests of Username and Password. Some as:

S:    334 VXNlcm5hbWU6
C:    avlsdkfj          <- Usename (base-64 encoded)
S:    334 UGFzc3dvcmQ6
C:    lkajsdfvlj        <- Password (base-64 encoded)

I've tried the command auth login (lower case) and auth=login without success.

I supposed that once obtained, the access the rest of the process is standard. Is to say some as:

C:    "MAIL FROM:<....>\r\n"
S:    250 .....
C    "RCPT TO:  ..\r\n"
S:    250 ...
C:    "DATA\r\n"
S开发者_开发技巧:    354 ...
C:    bla, bla, bla        <-  message- body
C:    \r\n.\r\n
S:    250 ...
C:    "QUIT\r\n"
S:    221 ...


As usual, sometimes the most obvious is the last hypothesis. In my problem, I was using a plain command

C: AUTH LOGIN

instead of

C: AUTH LOGIN\r\n

Note that you don't need append \r\n when using Telnet in Windows.

Be aware of use the same appendix when sending the encoded user-name and password.

By the way, besides the received comments, the page of Erwin Hoffmann SMTP Authentication Tutorial was a greath help to me.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜