Linux help needed: sending email

Discussion of chess software programming and technical issues.

Moderator: Ras

User avatar
hgm
Posts: 28390
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Linux help needed: sending email

Post by hgm »

I would like to send e-mail from the Linux command line. It seems there is a command "sendmail" to do that, but it does not seem to work. (In fact it gets stuck; when I use "sendmail -t < file" I won't get a new prompt until I kill it with Ctrl-C.)

What exactly should I do to get this working? Basically the only thing I know about e-mail is that I have a program called Eudora running under Windows, and that I can press a "send" button there to send a message I typed. That is the complete extent of my knowledge on this subject. Now how do I get from there to having sendmail (or something similar) work on Linux?

The reason I want this is to have my Internet Chess Server deliver e-mails, so that people can use the "mailstored" command to have games sent to them. Currently, when they do that, the game appears as a file called "mail.xxxxx" in a directory "spool" on my server machine. That is where they stay, unless I use a script (that was delivered with the ICS) to periodically send and delete such files. But this script calls "sendmail", with does not do anything. The deleting of the files works OK, though.

On the upside: The mailed games will contain the score/depth info that the engines kibitzed to them, if you choose PGN format! 8-)
User avatar
mhull
Posts: 13447
Joined: Wed Mar 08, 2006 9:02 pm
Location: Dallas, Texas
Full name: Matthew Hull

Re: Linux help needed: sending email

Post by mhull »

hgm wrote:I would like to send e-mail from the Linux command line. It seems there is a command "sendmail" to do that, but it does not seem to work. (In fact it gets stuck; when I use "sendmail -t < file" I won't get a new prompt until I kill it with Ctrl-C.)

What exactly should I do to get this working? Basically the only thing I know about e-mail is that I have a program called Eudora running under Windows, and that I can press a "send" button there to send a message I typed. That is the complete extent of my knowledge on this subject. Now how do I get from there to having sendmail (or something similar) work on Linux?

The reason I want this is to have my Internet Chess Server deliver e-mails, so that people can use the "mailstored" command to have games sent to them. Currently, when they do that, the game appears as a file called "mail.xxxxx" in a directory "spool" on my server machine. That is where they stay, unless I use a script (that was delivered with the ICS) to periodically send and delete such files. But this script calls "sendmail", with does not do anything. The deleting of the files works OK, though.

On the upside: The mailed games will contain the score/depth info that the engines kibitzed to them, if you choose PGN format! 8-)
http://www.cyberciti.biz/faq/linux-send ... m-console/
Matthew Hull
User avatar
hgm
Posts: 28390
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Linux help needed: sending email

Post by hgm »

Unfortunately, that does not help much. It certainly does not work. I guess the snag is:
Please note that above command will NOT route an email if you do not have properly configured MTA/mail server.
After which I am stuck again as I have no idea what an MTA/mail server is...
Sven
Posts: 4052
Joined: Thu May 15, 2008 9:57 pm
Location: Berlin, Germany
Full name: Sven Schüle

Re: Linux help needed: sending email

Post by Sven »

hgm wrote:Unfortunately, that does not help much. It certainly does not work. I guess the snag is:
Please note that above command will NOT route an email if you do not have properly configured MTA/mail server.
After which I am stuck again as I have no idea what an MTA/mail server is...
MTA = Mail Transfer Agent
You have that already as part of your Linux system (usually it is the "sendmail" program). If your computer running Linux is connected to the Internet then give it a try:
% echo "hello" | mail -s "hello" your@mail.address.com

If this does not work then add the "-v" (verbose) option to the "mail" command, and come back with the error output. Maybe someone is around here who could help in this case (I can't since I do not have experience in configuring "sendmail").

Sven
User avatar
hgm
Posts: 28390
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Linux help needed: sending email

Post by hgm »

When I type the command, nothing happens. I am connected to the internet in the sense that I can use FireFox to see web pages. But if I go to the webmail site of my provider to see if the message arrived, there is nothing.

The verbose does not seem to work:

Code: Select all

hgm@hgm-laptop:~/lasker-2.2.3/src$ echo hello | mail -v -s "hello" x.x.muller@hccnet.nl
mail: invalid option -- v
User avatar
hgm
Posts: 28390
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Linux help needed: sending email

Post by hgm »

sendmail does know the -v option, though:

Code: Select all

hgm@hgm-laptop:~/lasker-2.2.3/src$ sendmail -v x.x.muller@hccnet.nl
dit is een test
.
LOG: MAIN
  <= hgm@hgm-laptop U=hgm P=local S=304
hgm@hgm-laptop:~/lasker-2.2.3/src$ delivering 1N90ZU-0004AM-Gs
R: nonlocal for x.x.muller@hccnet.nl
LOG: MAIN
  ** x.x.muller@hccnet.nl R=nonlocal: Mailing to remote domains not supported
LOG: MAIN
  <= <> R=1N90ZU-0004AM-Gs U=Debian-exim P=local S=1108
LOG: MAIN
  Completed
delivering 1N90Zf-0004AS-V4
R: system_aliases for hgm@hgm-laptop
R: userforward for hgm@hgm-laptop
R: procmail for hgm@hgm-laptop
R: maildrop for hgm@hgm-laptop
R: lowuid_aliases for hgm@hgm-laptop (UID 1000)
R: local_user for hgm@hgm-laptop
T: appendfile for hgm@hgm-laptop
LOG: MAIN
  => hgm <hgm@hgm-laptop> R=local_user T=mail_spool
LOG: MAIN
  Completed
I guess this is not good:
** x.x.muller@hccnet.nl R=nonlocal: Mailing to remote domains not supported
User avatar
michiguel
Posts: 6401
Joined: Thu Mar 09, 2006 8:30 pm
Location: Chicago, Illinois, USA

Re: Linux help needed: sending email

Post by michiguel »

hgm wrote:When I type the command, nothing happens. I am connected to the internet in the sense that I can use FireFox to see web pages. But if I go to the webmail site of my provider to see if the message arrived, there is nothing.

The verbose does not seem to work:

Code: Select all

hgm@hgm-laptop:~/lasker-2.2.3/src$ echo hello | mail -v -s "hello" x.x.muller@hccnet.nl
mail: invalid option -- v
Hi Harm,

I am in your same situation, but I was doing a bit a research before. I am not an expert on this but apparently you need access to an smtp server, you need installed an smtp client, and you need a mail client/agent. The mail agent uses the smtp client to connect to the server.

I have not install it yet (I was planning to do this the next few days) but apparently you need
http://msmtp.sourceforge.net/
and
http://www.mutt.org/
and an provider that can work as an smtp server. As far as I know, gmail now can do that.

I have used mutt when I was at Michigan State University and it was great. Better than mail. You can easily send attachments etc.

Miguel
zamar
Posts: 613
Joined: Sun Jan 18, 2009 7:03 am

Re: Linux help needed: sending email

Post by zamar »

I think, you need to reconfigure your MTA (=mail transport agent).

In my debian installation default MTA is exim4. To reconfigure it I simply run "dpkg --reconfigure exim4" (but this depends on linux distribution). To be able to send mail to remote domains, you need access to SMTP-server and you need to configure your MTA to use this SMTP-server. Most internet access providers have their own SMTP-server, usually sth like "smtp.foo.com".

I'm far from expert in this area...
Joona Kiiski
User avatar
hgm
Posts: 28390
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Linux help needed: sending email

Post by hgm »

OK, thanks, this solves it! I tried

Code: Select all

dpkg-reconfigure exim4-config
and this steps me through a menu where I could change the basic mode to sending mail through a smarthost (and not receiving any). In my Eudora options I found a field that contained smtp.hccnet.nl, which I used as the smarthost name.

It now sends the message, and I actually received it. The sender that it lists is an invalid e-mail address, though: it strings my Linux username with the domain name of my provider (whose smarthost I am using). Well, never mind, I would not want to have any replies anyway.
bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: Linux help needed: sending email

Post by bob »

hgm wrote:I would like to send e-mail from the Linux command line. It seems there is a command "sendmail" to do that, but it does not seem to work. (In fact it gets stuck; when I use "sendmail -t < file" I won't get a new prompt until I kill it with Ctrl-C.)
Did you try "^D" which is a classic eof? however, using sendmail is probably not the right solution anyway, there are a ton of front-ends to sendmail. mail, mailx, pine, elm, etc. Sendmail is the transport program, but is normally accessed from some sort of front end.

What exactly should I do to get this working? Basically the only thing I know about e-mail is that I have a program called Eudora running under Windows, and that I can press a "send" button there to send a message I typed. That is the complete extent of my knowledge on this subject. Now how do I get from there to having sendmail (or something similar) work on Linux?

The reason I want this is to have my Internet Chess Server deliver e-mails, so that people can use the "mailstored" command to have games sent to them. Currently, when they do that, the game appears as a file called "mail.xxxxx" in a directory "spool" on my server machine. That is where they stay, unless I use a script (that was delivered with the ICS) to periodically send and delete such files. But this script calls "sendmail", with does not do anything. The deleting of the files works OK, though.

On the upside: The mailed games will contain the score/depth info that the engines kibitzed to them, if you choose PGN format! 8-)