SMTPClient and hMailServer

18 Jan 2012

Hello to everybody, well, after one days pushing my head against the wall, I was able to make works SMTPClient with hMailServer, the problem is a little diference in the protocol, and you must modify the library.

As I can read somewhere, the protocol need a "<login>\0<login>\0<password>" encoded string to autenticate the client, but hMailServer works using "\0<login>\0<password>" encoded string. This can be found reading logs, I used a mozilla file client configured to use hMailServer to make it works properly and then reading the logs against my mbed communication strings.

The changes in library are (SMTPClient.cpp line 72):

from (original):

string SMTPClient::encodePlainAuth() {
    string decStr = m_username;
    decStr  = '\0';
    decStr  = m_username;
    decStr  = '\0';
    decStr  = m_password;

    string auth = "AUTH PLAIN ";
    return auth.append(Base64::encode(decStr));
}

to:

string SMTPClient::encodePlainAuth() {
    string decStr;// = m_username;
    decStr  = '\0';
    decStr  = m_username;
    decStr  = '\0';
    decStr  = m_password;

    string auth = "AUTH PLAIN ";
    return auth.append(Base64::encode(decStr));
}

I hope this can help, is realy usefull because allow to use a propetary mail server installed in your home or work to send emails.

Best regards,

JP Cordova E.