-
Sendmail
Posted on April 5th, 2009 No commentsTodays lesson is about Mail.
Sendmail is a standard tool for your e-mail needs. There’s alot more to it than I am aware of at this point. Right now, I just need to make sure I can e-mail OUT to the rest of the internet/world.
To understand a little bit about e-mail and how it all works, you can check this link that briefly explains the purpose and operation of MDAs (Mail Delivery Agents), MTAs (Mail Transfer Agents) and MUAs (Mail User Agents). This information should come in handy in setting up your own agent.
Sendmail is an MTA as it can transfer e-mail for you, sending and recieving. I however just have the need to send mail. I had problems for a while, then I found a nice simple program called sendEmail. It was simple enough to run without having to configure anything. But I could not get sendmail to work for some reason. My sendEmail program worked, but not sendmail. Why?
To figure this out, I had to figure out how the MTA of my local ISP was working. Talking with my coworkers, I learned that one can telnet directly into an SMTP server and issue commands from there and send out an e-mail directly. I gave it a try, and everything worked until I got to the point of telling the server who I wanted to e-mail. It was then I got the response: 550 Recipient Rejected: Relay not allowed. What was I doing wrong?
Now I was successful in sending e-mails with sendEmail, so I needed to see what was different.
It was then that I downloaded WireShark, which I was eventually going to want anyway. I’ll have to blog about that program another day as well. But for now, I’ll just say that I was able to capture all data going in and out of my eth1 interface and see what was transpiring. It was there that I saw a command I was not aware of, AUTH LOGIN followed by encrypted data. AHA!! That was the answer.
It wasn’t so much that I was doing something wrong, it was that my ISPs server was setup for authentication, of which it was not getting from me. Another search online yielded this fine set of instructions. You’ll need to scroll halfway down the page for the heading Using sendmail as a client with AUTH.
After this setup I was successful in e-mailing myself.
If you are not interested in telnetting into your SMTP server or using WireShark, you can see what’s going on by using the -v option while using the mail command. Below is a successful example.
mail -v -sTesting user@yahoo.com Command from terminal
(blue text is from my box, red from the server)
user@isp.com… Connecting to [127.0.0.1] via relay…
220 ubuntu ESMTP Sendmail 8.14.3/8.14.3/Debian-4; Fri, 3 Apr 2009 18:24:08 -0800; (No UCE/UBE) logging access from: localhost(OK)-localhost [127.0.0.1]
>>> EHLO ubuntu
250-ubuntu Hello localhost [127.0.0.1], pleased to meet you
250-ENHANCEDSTATUSCODES
250-PIPELINING
250-EXPN
250-VERB
250-8BITMIME
250-SIZE
250-DSN
250-ETRN
250-AUTH DIGEST-MD5 CRAM-MD5 LOGIN PLAIN
250-DELIVERBY
250 HELP
>>> VERB
250 2.0.0 Verbose mode
>>> MAIL From:<lance@ubuntu> SIZE=69 AUTH=lance@ubuntu
250 2.1.0 <lance@ubuntu>… Sender ok
>>> RCPT To:<user@yahoo.com>
>>> DATA
250 2.1.5 <user@yahoo.com>… Recipient ok
354 Enter mail, end with “.” on a line by itself
>>> .
050 <user@isp.com>… Connecting to smtp.local.net via relay…
050 220 smtp.local.net ESMTP EON-AUTHRELAY2
050 >>> EHLO ubuntu
050 250-smtp.local.net
050 250-PIPELINING
050 250-SIZE 50000000
050 250-AUTH PLAIN LOGIN
050 250-AUTH=LOGIN
050 250 8BITMIME
050 >>> AUTH LOGIN
050 334 <encrypted – text>
050 >>> <encrypted – text>
050 334 <encrypted – text>
050 >>> <encrypted – text>
050 235 Authentication successful
050 >>> MAIL From:<lance@ubuntu> SIZE=333 AUTH=<>
050 250 Sender okay
050 >>> RCPT To:<user@yahoo.com>
050 >>> DATA
050 250 Recipient okay
050 354 Ready
050 >>> .
050 250 Thanks, queued as dm52.49d40e27.c9ac3@dm52
050 <user@yahoo.com>… Sent (Thanks, queued as dm52.49d40e27.c9ac3@dm52)
250 2.0.0 n342O8aV020851 Message accepted for delivery
user@yahoo.com… Sent (n342O8aV020851 Message accepted for delivery)
Closing connection to [127.0.0.1]
>>> QUIT
221 2.0.0 ubuntu closing connection




