On Sat, May 01, 2010 at 07:12:54AM -0400, Jim Perrin (jperrin at gmail.com) wrote: > On Sat, May 1, 2010 at 5:52 AM, hadi motamedi <motamedi24 at gmail.com> wrote: [snip] > Several things are wrong with this: > > 1. DO NOT EVER USE TELNET. <just to be picky ;-)> While I 100% agree with this you need to refine the wording a little > 1. DO NOT EVER USE TELNET TO LOGIN. Telnet is still a VERY VERY worthy tool to debug e.g. a mail/imap/pop/whatever conection and I would not want to live without it, even for HTTP connections, the only thing you need to know is the protocol you want to debug. telnet mail.domain.ext 25 If you establish a sucessful connection you will see something like Connected to mail.domain.ext. Escape character is '^]'. 220 domain.ext ESMTP MDaemon 6.7.6; Tue, 25 Mar 2003 11:37:02 +0000 The next step is to tell the mail server where you are mailing from. This is the FQDN or the IP address of your local machine HELO local.domain.name A well configured mail server will check you are who you say you are (so, if you lie about your machine FQDN or IP, you may well caught), then respond 250 mail.domain.ext Hello local.domain.name [a.b.c.d], pleased to meet you Next you specify who the mail is from MAIL FROM: mail at domain.ext which should return 250 2.1.0 mail at domain.ext... Sender ok Some mail servers will check that the domain you use in the MAIL FROM: command exists. Now tell the mail server who the email is to RCPT TO: mail at destinationdomain.ext which should return 250 2.1.0 mail at destinationdomain.ext... Recipient ok Now tell the mail server that you are going to send the email DATA Now you can start writing your email. Start by entering the email headers. Note the space between the : terminating the header name and the value. This is mandatory. From: Your Name To: Their name CC: Someone else Subject: Your subject. Once you finished with your header, press enter to leave a blank line before you begin the message body, then enter your email contents. To tell the mail server that you have completed the message enter a single "." on a line on its own. The mail server should reply with something like 250 2.0.0 OK Message saved for delivery You should close the connection by issuing the QUIT command. The mailserver should sign off with something like: 221 2.0.0 mail.domain.ext closing connection Connection closed by foreign host. </just to be picky ;-)> Jobst > Seriously. Don't do this. It sends your user/pass in plain text. It's > a horrendous security risk. I don't care what excuse you have to try > to defend it. DO NOT DO IT. Use ssh keys instead. > > 2. Use ssh keys instead of setting a password in the script. > > 3. You don't need to use expect to set the PWD to /tmp. You can do > this with basic scripting. Pick up a bash scripting guide and read > through it. I see almost nothing in your example that requires expect. > This can be done with a simple bash script. > > > > > -- > During times of universal deceit, telling the truth becomes a revolutionary act. > George Orwell > _______________________________________________ > CentOS mailing list > CentOS at centos.org > http://lists.centos.org/mailman/listinfo/centos -- Tommorow or the next life, whichever comes first, we never know. - Saying from Tibet. | |0| | Jobst Schmalenbach, jobst at barrett.com.au, General Manager | | |0| Barrett Consulting Group P/L & The Meditation Room P/L |0|0|0| +61 3 9532 7677, POBox 277, Caulfield South, 3162, Australia