Saturday, April 18, 2009

How to send email from scripts running on DNS-323

In the full installation of ffp 0.5, two email related utilities are installed by default. They are
  1. mailx - a Mail User Agent which allows you to send and receive mail using command line parameters, and
  2. esmtp - a Mail Transfer Agent which transfer mail from one computer to another
Unfortunately, they are not setup properly out-of-the-box hence you won't be able to use them right away. There also isn't any mention of how to do this on the wiki nor the package readme files.

Well, as it turned out, it wasn't that hard to get it up and running anyway which might explain the lack of documentation. But for the uninitiated, all you need is to create a config file called esmtprc in your /ffp/etc folder and input your mail provider details there. To learn more about how to configure the esmtprc file, take a look at this sample.

Then to send mail, use the mailx command syntax like this

> cat /bs/some_file.txt mailx -s "the email subject line" -r

which sends the content of the file "some_file.txt" as the body of the message, or to send it as an attachment, use this

>mailx -s "this is your subject line" -a /bs/some_file.txt -r

To use gmail as your mail provider, you may want to check out this forum post.


heliotrope said...

Can you provide some details on where you put the config files and how you made them? My setup is giving me trouble.

MaryG said...

Can you help with this problem with mailx (on DNS-323):
Assume I have a file which reads:
Subject: Test of mailx
This is a message
When I then go:
mailx -t < file
Then I get this error: "No recipients specified"
Many thanks in advance - Mary

Joe T. said...

Ok The sourceforge pages are mostly missing and I'm getting:
SMTP server problem Name or service not known. I'm stuck. I'm using mail.