Re: lynx send-mail from script ?
- From: "Enrique Perez-Terron" <enrio@xxxxxxxxx>
- Date: Sat, 31 Dec 2005 12:14:12 +0100
On Sat, 31 Dec 2005 07:57:07 +0100, moma <moma@xxxxxxxxxxx> wrote:
news@xxxxxxxxxxxxxx wrote:
I want to similarly send a set of pre-written emails via the
same script.
Is this possible & how ?
== Chris Glur.
hope we do get spammed ;--)
can't you use 'mail' or 'mutt'?
$ man mail
$ man mailx
$ man mutt
The oldest Unix email I know of used this syntax to send mail:
mail -s "subject" recipient@host < mailfile
but it actually invokes "sendmail" to do the delivery. Configuring
sendmail is **dificult**. Postfix is somewhat easier. Most systems
come with sendmail already installed.
The trouble is that the standard sendmail config supposes that your
computer is a first-class citizen of the Internet, with it's own
properly registered dns hostname. Then sendmail would use DNS to
figure out what computer to relay the mail to for the given recipient
address.
Most people don't have a domain, and if sendmail tries to contact the
recipient's mail server directly, that mail server will normally refuse
to accept the mail. This is a kind-of anti-spam accountability thing.
A solution to this is to configure sendmail with a "smart host", which
will be you ISP's smtp server. Then sendmail will relay all mails through
that server, except when posting local mail, like when cron posts mail to
root.
Newer sendmail installations have a system of configuration macros that
make it somehwat easier to achieve the most common configuration types.
Supposing that your distro has not changed the default setup too much,
and that my distro the same, find the file /etc/mail/submit.mc, and
add some lines like this:
define(`confDONT_INIT_GROUPS', `True')dnl
define(`confPID_FILE', `/var/run/sm-client.pid')dnl
dnl define(`confDIRECT_SUBMISSION_MODIFIERS',`C')
+define(`SMART_HOST', `smtp.online.no')
FEATURE(`use_ct_file')dnl
+FEATURE(`masquerade_envelope')dnl
+MASQUERADE_AS(`online.no')dnl
dnl If you use IPv6 only, change [127.0.0.1] to [IPv6:::1]
FEATURE(`msp', `[127.0.0.1]')dnl
(The lines with '+' are the added lines. Omit the '+'. I am not sure
about the rules for the order of these lines, my first attempt failed,
and then I moved the MASQUERADE line above the "FEATURE(`msp'" and then
it worked. I think all "define" lines shall be first, before the first
FEATURE. The pre-existing lines may be similar or different in your
installation. )
Do keep a backup of the file before any modifications, so you can revert any
changes!
Notice that "online.no" is my ISP's domain. "smtp.online.no" is my ISP's
outbound mail server.
Then, as root, do "cd /etc/mail; make; /etc/init.d/sendmail restart". It
requires that you have "make" installed.
This will make many programs mail-capable, e.g. emacs. In the origninal
Unix philosophy, any program could be mail-capable by invoking sendmail.
Notice that when using a substitute for sendmail, as postfix or qmail,
then /usr/lib/sendmail is a link to the substitute.
---
I had a quick look at the manpage for mutt/muttrc, and I could not find
how to configure mutt to bypass sendmail and use my ISP's smtp server
directly. I have used mutt in the past, but I don't remember if I had
it submit mail through sendmail, as is obviously its default. Otherwise
it seems you can use mutt using the same syntax as mail.
Strange, I have something in the back of my mind nagging that it is
possible to send mail without first configuring sendmail. At a time I
used pine, could it be it?
It think mail needs a 'fetchmail', 'sendmail' or 'postfix' to deliver
and fetch while snailmail needs feet.
I can't imagine you need fetchmail to *send* anything. Fetchmail is for
contacting pop servers and download incoming mail.
Study
http://www.shelldorado.com/articles/mailattachments.html
Nice page, but it does not seem to address the problem that I address
with the masquerade config above.
-Enrique
.