Using mmencode for authenticated SMTP sessions
To authorize via smtp, you must first obtain a login string using mmencode and printf. Echo does not work. mmencode is part of the Metamail package. I had trouble finding is, so I placed the source rpm (RHEL)here:
- metamail-2.7-9.ker.rhel3.src.rpm.
- metamail-2.7-9.ker.rhel3.i386.rpm (no XFree86 support)
You can encode and decode using mmencode.
Using mmencode to encode text
Using mmencode to decode text
Example SMTP AUTH Session using AUTH PLAIN
235 Authentication succeeded.
250 Sender accepted.
250 Recipient accepted.
354 End your message with a period.
250 Accepted message qp 847 bytes 247 quit 221 Good bye.
Example SMTP AUTH Session using AUTH LOGIN
To use auth login, you will need to encode the username and password seperately. As before, you can use either one of the two printf methods:
- OR -
Part of the trick to using AUTH LOGIN mode is decyphering the server responses. To decode the responses, simply print the string back into mmencode using the -u option as shown above.
250 Sender accepted.
250 Recipient accepted.
354 End your message with a period.
250 Accepted message qp 847 bytes 247 quit 221 Good bye.
Unencode a password/username with mmencode
To unencode a mmencoded string, pass the string to mmencode -u
printf (mmencode) breaks with numeric passwords
While I was troubleshooting an issue one day, I noticed that a numeric password (or at least a password that started with a number) would parse incorrectly. For instance a password of '799pass' would unencode as '99pass'. That's because the printf command saw the numbers following the '\0' null as part of an octal sequence (except for the 9's of course since octal stops at 7). This problem is readily apparent in almost all the examples on the internet:
A better way to do this is to provide the format and the arguments as seperate arguments to printf (like in C).