[Serusers] V_M and SMTP Auth - Resolved

Ian Bonham ianbonham at sftalk.net
Fri Jan 7 21:46:52 CET 2005


Hi All,

It is with a sense of achievment I can report that as a non-C++ coder I've
managed to solve this one. I thought I'd post on my experiences for reference
incase anyone has the same probs.

I had to (for a number of reasons) post my email messages containing voice
mail through my 1&1.co.uk smtp server. The problem I had was that SEMS doesn't
handle AUTH commands in it's mail module.

As an inexperienced coder, I hacked my way through this, and this is how I
managed it incase anyone else needs it.

First off, I have a webmail interface on the box hosting my email front end.
The webmail interface sits on 1 server and the email SMTP engine on a
completly different server on another part of the net. I used SSH to get into
the webmail backend, and ran :

ngrep -qtt port 25

On the webmail server. This let me watch what was happening when I sent a mail
from the webmail php engine through to the remote smtp server. I could study
the command that went through from the php in the webmailer to the smtp
server. The output was thus :

T 2005/01/07 17:38:01.322600 212.227.15.179:25 -> 217.160.187.14:32970 [AP]
  250-mrelayng.kundenserver.de Hello www.sftalk.net [217.160.187.14]..250-SIZE
20971520..250-
  PIPELINING..250-AUTH=PLAIN LOGIN..250-AUTH PLAIN LOGIN..250-STARTTLS..250
HELP..

T 2005/01/07 17:38:01.323587 217.160.187.14:32970 -> 212.227.15.179:25 [AP]
  AUTH LOGIN..

T 2005/01/07 17:38:01.324102 212.227.15.179:25 -> 217.160.187.14:32970 [AP]
  334 VXNlcm5hbWU6..

T 2005/01/07 17:38:01.324843 217.160.187.14:32970 -> 212.227.15.179:25 [AP]
  <REMOVED FOR SECURITY>

T 2005/01/07 17:38:01.325515 212.227.15.179:25 -> 217.160.187.14:32970 [AP]
  334 UGFzc3dvcmQ6..

T 2005/01/07 17:38:01.326186 217.160.187.14:32970 -> 212.227.15.179:25 [AP]
  <REMOVED FOR SECURITY>

T 2005/01/07 17:38:01.355346 212.227.15.179:25 -> 217.160.187.14:32970 [AP]
  235 Authentication succeeded..

>From here I could work out the communication process that was happening
between SMTP AUTH and the webmail interface. It was then a process of reading
the C++ step by step to see how that could be hacked (and I'm sure it's a well
dirty hack) to get SEMS using an AUTH smtp server.

Opening AmSmtpClient.cpp in the Answer_Machine tree, you can see where the
initial communication with your destination SMTP server (as specified in
sems.conf) starts. At line 94, theres the command :

    if(cont){

which starts the communication with the SMTP server. I needed to stop the
system going on to :

	INFO("%s welcomes us\n",server_ip.c_str());

immedianly, as we needed to AUTH the server. So, using the information we got
from the NGREP trace, we know that as soon as we hit :

    INFO("connected to: %s\n",server_ip.c_str());
    bool cont = !get_response(); // server's welcome

(lines 92 & 93) we need to send in a new command for AUTH. We can do this by
immediantly sending an 'AUTH LOGIN' message. Immediantly after line 94
<if(cont){> add the command :

	send_command("AUTH LOGIN");

This triggers the authorisation process. Then we need to respond to the
server. From the NGREP trace, I know 1&1 reply with :

T 2005/01/07 17:38:01.324102 212.227.15.179:25 -> 217.160.187.14:32970 [AP]
  334 VXNlcm5hbWU6..

At the moment I just gamble thats the reply, so then I send back the next line
from the NGREP trace, which would be send in this way :

	send_command("<removed for security>");

but replace <removed for security> with the response you got earlier in the
NGREP.
Next we need to send a password. Again, I'm just presuming that we have
reached the stage where the SMTP server wants the password, so next I send in
:

	send_command("<removed for security>");

This is the password, as would be sent by a 'proper' smtp client, that we got
from the NGREP trace earlier. This should normally send back the response :

T 2005/01/07 17:38:01.355346 212.227.15.179:25 -> 217.160.187.14:32970 [AP]
  235 Authentication succeeded..

Now we can continue to process the AmSmtpClient procedure. You should find now
that the system can send email via a remote AUTH SMTP server. So your final
edit of the AmSmtpClient.cpp should read (at line 95) :

    if(cont){
	send_command("AUTH LOGIN");
	send_command("<removed>");
	send_command("<removed>");
	INFO("%s welcomes us\n",server_ip.c_str());
	return send_command("HELO " + server_ip);
    }
    else
	return true;

Substitute <removed> as the strings you get from the NGREP trace, and you
should find that SEMS can now send email vm messages using your AUTH SMTP
server. Don't forget to recompile with the edited code!!!!

I fully accept that this is a DIRTY hack, but it worked for me. Maybe someone
out there with better C++ understanding than me could improve it, adding an
auth flag to sems.conf and a couple of fields for auth_user and auth_passwd,
but thats beyond me till I learn more.

Hopefuly this'll help you out tho if you have the same probs as I had.

If anyone needs any more help on this give me a shout,

Meantime, Thanks to everyone thats given up time and effort helping me learn
so far, and for developing this great software.

All the best,

Bon


Ian Bonham (ianbonham at sftalk.net) wrote: (
>
> Hi all,
>
> I'm sure someone will be able to advise me on this. I'm using SEMS as my
> Voicemail service, and in this case I have to relay the voicemail messages
> through an Authorisation SMTP server.
>
> I would use sendmail on localhost, but if I try to send a message to my own
> email address using localhost on 1&1's servers the message never gets to me :(
>
> Is there any way to edit the AmMail.cpp to allow it to handle auth'd SMTP? If
> so, can anyone let me know the procedure please? Then I can send my mail
> through my 1&1 SMTP server
>
> Many thanks,.
>
> Ian Bonham
>
> _______________________________________________
> Serusers mailing list
> serusers at lists.iptel.org
> http://lists.iptel.org/mailman/listinfo/serusers
>




More information about the sr-users mailing list