Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Ken, why did you hi-jack this thread only to whine about not being able to use a solution that doesn't meet YOUR criteria?
I sure didn't intend to. The OP said, "Postfix, Dovecot, MySQL, and SpamAssasin seem pretty involved." I understood his request to be just about the same as what I'm after, including my "simplicity criterion."
I'm actually shocked at TBOne's response. He seems truly offended that I've rejected sendmail, even to the point of insulting me. ("If you can't understand the solution,...")
Two potential solutions I haven't had a chance to look into yet are qpsmtpd and simple-smtpd-coro. They're both written in Perl. I may be able to modify one or the other to get just what I want.
Quote:
Originally Posted by TB0ne
No, you don't have to do that at all. You can easily use tee or a simple pipe to shovel script-status outputs through your mail system.
I'm looking for a "your mail system". I don't understand why this is so difficult to convey. Let's take a very specific example. My system includes the cronie package which comes with file /etc/cron.d/0hourly:
Code:
# Run the hourly jobs
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
01 * * * * root run-parts /etc/cron.hourly
I want whatever results there are emailed to me. So what do I edit? This file? It's inadvisable to edit files that are part of released packages because if they release an update, I'll have to notice it and take manual action.
But with the simple solution I have in mind, cron will send outputs to 'root' and my smtpd daemon will receive it and call my script that will pass that email to my MDA.
-
I'm looking for a "your mail system". I don't understand why this is so difficult to convey. Let's take a very specific example. My system includes the cronie package which comes with file /etc/cron.d/0hourly:
Code:
# Run the hourly jobs
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
01 * * * * root run-parts /etc/cron.hourly
I want whatever results there are emailed to me. So what do I edit? This file? It's inadvisable to edit files that are part of released packages because if they release an update, I'll have to notice it and take manual action.
But with the simple solution I have in mind, cron will send outputs to 'root' and my smtpd daemon will receive it and call my script that will pass that email to my MDA.
-
You don't need to modify anything in that file, what I would do in '/etc/cron.hourly' is create a crontab that calls your script.
This way you have not modified anything, you simply added a file to /etc/cron.hourly that happens run your scripts. They can update the package all they want, you won't clobber existing files (at least any sane distro wouldn't)
You can skip the SMTP deamon all together with a perl script (since perl is considered part of the core distro) All you would need to download in one library that perl script needs.
You can now send that data to any email account you want, as long as you know where you are sending it (SMTP settings of that email)
Code:
#!/usr/bin/perl
use strict;
use warnings;
use Net::SMTP;
use POSIX qw/strftime/;
my $smtp = Net::SMTP->new('SMTP_SERVER');
my $file= "<File you want to send>";
my $datestring = strftime("%m-%d-%Y", localtime);
$smtp->mail('someguy@someemail.com');
$smtp->data();
$smtp->datasend("From: someserver\@somecompany.com\n");
$smtp->datasend("Subject: Server Error Report $datestring\n");
$smtp->datasend("To:someuser\@somecompany.com\n");
$smtp->datasend("\n");
#make sure file exists
if (-e $file) {
#read the file one line at a time
open( RFILE, "<$file" )||print "could not open file";
while (my $line = <RFILE>){
$smtp->datasend("$line");
}
close(RFILE) || print "could not close file \n";
}
else {
print "did not find the report $file \n";
exit 1;
}
$smtp->dataend();
$smtp->quit;
So point this at logs and it will send the contents of them, if you don't want to email the contents of a log, send the messages you want to a file and tell perl where it is, it will send the contents of that file instead.
I sure didn't intend to. The OP said, "Postfix, Dovecot, MySQL, and SpamAssasin seem pretty involved." I understood his request to be just about the same as what I'm after, including my "simplicity criterion."
I'm actually shocked at TBOne's response. He seems truly offended that I've rejected sendmail, even to the point of insulting me. ("If you can't understand the solution,...")
First, I don't care what you reject. The solution is very simple, but you can't see it, and are either intentionally ignoring what's said, or truly don't understand. Second, when you make comments like this:
Quote:
Originally Posted by KenJackson
Stop shoving sendmail down my throat. Shove it somewhere else.
...you have NO business being shocked at the responses you get from anyone. /dev/random and jpollard both echo this solution for a reason. It works.
Quote:
Two potential solutions I haven't had a chance to look into yet are qpsmtpd and simple-smtpd-coro. They're both written in Perl. I may be able to modify one or the other to get just what I want.
I'm looking for a "your mail system". I don't understand why this is so difficult to convey. Let's take a very specific example. My system includes the cronie package which comes with file /etc/cron.d/0hourly:
Code:
# Run the hourly jobs
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
01 * * * * root run-parts /etc/cron.hourly
I want whatever results there are emailed to me. So what do I edit? This file? It's inadvisable to edit files that are part of released packages because if they release an update, I'll have to notice it and take manual action.
But with the simple solution I have in mind, cron will send outputs to 'root' and my smtpd daemon will receive it and call my script that will pass that email to my MDA.
...and this, from /dev/random:
Quote:
Originally Posted by /dev/random
You don't need to modify anything in that file, what I would do in '/etc/cron.hourly' is create a crontab that calls your script.
..is EXACTLY why I said you didn't understand the solution. This is EXACTLY what was said before, and it still holds true. And you can just set up a mail alias for either sendmail or postfix (which can then send the same email to MULTIPLE addresses...which is what you want), and it gets even easier, which is exactly one (1) line in the mailer daemon file, and entering the addresses once.
Or, as said before, use mailx, and enter whatever your current mailer criteria is into it, and use that.
You don't need to modify anything in that file, what I would do in '/etc/cron.hourly' is create a crontab that calls your script.
No.
You cannot use a script to capture email to "root" that cron sends to port 25 when it runs a system cron script (without modifying the system scripts). I need a daemon.
I know what I need, I'm part way there and I have a pretty good idea of how to get there. I just posted here because I think surely someone has already done this and I'm just not looking in the right place. But instead I get a load of advice telling me not to do what I want, but to do something else instead.
It's been a thoroughly frustrating experience.
Sorry, kb2tfa. I'm pretty sure you were asking for the simple solution I seek. I didn't mean to draw contention into your thread. When I get something working, I'll try to post it somewhere.
I'm going to try to ignore this thread from now on.
That was what I thought too.
Evidently the OP already had a solution in his mind and arbitrarily rejected any thing else - even if his solution wouldn't work.
It is POSSIBLE, MAYBE, REMOTELY... to redirect port 25 to a different host using IP tables- but not if that connection requires authentication.
Yep..I think descendant_command summed it up nicely. Apparently, everyone, everywhere who is using sendmail/postfix/mailx is doing it wrong, and none of us are getting mail from systems/cron.
I don't know if it's a resource hog or not, but at the moment it does what I want. I can send attachments although it's really just reading it in to a file, but works for sending a log if need be. I believe it can't receive mail, but that's fine with me. One way traffic will do the job.
echo "This is yet another test" | mail -s "This is a subject" you@youremail.com
NOW SEND OR READ IN AN ATTACHMENT
mail -s "Subject" email-recipient < text.txt
SEND CC OR BC
mail -s "Subject" email-recipient -c email-recipient -b email-recipient
***PRESS ENTER***
(add text for body here)
***Control-D***
I wasn't quite certain what the OP wanted, but I thought it might be the same thing I wanted. But I had immense difficulty explaining what that was.
Quote:
Originally Posted by KenJackson
I need two things: redirect cronjob mail to the mail-delivery-agent of my choice for local delivery, and forward other mail to my provider (yes, my smarthost).
Having ruled out the behemoths, I'm getting by with nothing at the moment. Thunderbird sends mail directly to my provider. I'm working on a perl script to do the job myself. It seems like SURELY someone else has already done this, but if they have, I can't find it.
Anyway, at long last I've published the solution that I developed and have been using for a few years. I don't know if anyone else will want it, but I find it invaluable.
I don't know if it's a resource hog or not, but at the moment it does what I want. I can send attachments although it's really just reading it in to a file, but works for sending a log if need be. I believe it can't receive mail, but that's fine with me. One way traffic will do the job.
mailx is a MUA...an email client like Outlook or Thunderbird. Like them, it can compose and connect to your MTA to send mail. It is also capable of reading mail. It does not, in itself, connect to the network to send or receive mail.
Edit: Sorry. I jumped in the middle of this and responded only to that post.
I can't help with sendmail/postfix...I use qmail on my server...mailx works just fine there by sending via qmail
I don't have a "simple" solution either. Setting up and maintaining a mail server (MTA) takes learning, diligence, and effort.
mailx is a MUA...an email client like Outlook or Thunderbird. Like them, it can compose and connect to your MTA to send mail. It is also capable of reading mail. It does not, in itself, connect to the network to send or receive mail.
Edit: Sorry. I jumped in the middle of this and responded only to that post.
I can't help with sendmail/postfix...I use qmail on my server...mailx works just fine there by sending via qmail
I don't have a "simple" solution either. Setting up and maintaining a mail server (MTA) takes learning, diligence, and effort.
Yep...that's why the OP and KenJackson were suggested to set up a simple smarthost further upstream, and let it do the heavy lifting. That way, a simple one-liner in postfix/sendmail config to shovel all the mail there is all that's needed. Past that, you only need to modify your user-scripts to send the mail as you see fit...no need for other programs, or spending time with a hugely-involved full-bore postfix/sendmail setup.
Personally, I find it fairly ironic that this thread had been closed for three years, before it was reopened. And that given the comments in post #12, and in other locations about not wanting sendmail 'shoved down his throat', the github page says:
Quote:
Originally Posted by GitHub Page
Although note that the cron daemon requires /usr/sbin/sendmail to deliver email. Therefore every computer that uses cron must have the 'sendmail' package or a simpler substitute such as 'ssmtp' (recommended) installed and configured to deliver email to the lansmtpd server.
(bold for emphasis only) So the solution to avoid sendmail is to write a program that uses sendmail? And this whole thing sounds **VERY MUCH** like just configuring a smarthost. Since any mail that comes in is only sent on to another server for processing. Which is exactly what was suggested three years ago.
Personally, I find it fairly ironic that this thread had been closed for three years, before it was reopened.
I found it thoroughly frustrating that I couldn't explain what I was looking for, so I wanted to finish off discussion by showing the solution. I couldn't do that until I made it presentable. I appreciate your time, but I don't need more help now that I have an excellent solution.
Quote:
Originally Posted by TB0ne
So the solution to avoid sendmail is to write a program that uses sendmail?
You're apparently not familiar with the ssmtp package. It most definitely is not sendmail, even though it provides a simple executable with the name hard-coded into cron.
I still don't understand the animosity, but I'm quite willing to discuss the solution more. Though it would be more appropriate in a new thread.
I found it thoroughly frustrating that I couldn't explain what I was looking for, so I wanted to finish off discussion by showing the solution. I couldn't do that until I made it presentable. I appreciate your time, but I don't need more help now that I have an excellent solution.
You misunderstand; we knew exactly what you were looking for. Glad you have a solution that works for you...maybe (?) someone else will want it.
Quote:
You're apparently not familiar with the ssmtp package. It most definitely is not sendmail, even though it provides a simple executable with the name hard-coded into cron.
Very familiar with it, and many other mail programs, thanks. And you were told about ssmtp in post #8 of this thread, three years ago.
Quote:
I still don't understand the animosity, but I'm quite willing to discuss the solution more. Though it would be more appropriate in a new thread.
No animosity at all, but given YOUR comments of "Stop shoving sendmail down my throat. Shove it somewhere else.", what do you expect???
Again, you seem to have reinvented the wheel. You posted (post #7):
Quote:
Originally Posted by KenJackson
I need two things: redirect cronjob mail to the mail-delivery-agent of my choice for local delivery, and forward other mail to my provider (yes, my smarthost).
Back to:
Rediect cronjob mail: Either put a simple mailx statement in your cron scripts to send the output to whoever you want, or write a simple script to scan the mailqueue directory and act based on name.
Forward to mail provider: Single line in postfix/sendmail config sends to smarthost, using the aforementioned mailx program.
Done.
I use (and have used) both for MANY years, with zero problems. When I can set up a single relay host, and have all my internal servers point to it, using programs that come with Linux, and accomplish this (and more), that's what I'll go with.
Great that you spent all that time doing your own thing, glad it works for you, but I certainly can't see a need for it. Maybe someone else will. Good luck.
Yet you didn't seem to appreciate that it requires only one line of configuration (Mailhub) (excellent!), so it works perfectly and beautifully for all machines but the server. But that it can't work on the server because it can't separate and deliver to local addresses (bad). That is, mail to "user@box.com" must be forwarded to my provider, but to "user@box" must be delivered to a mailbox on the server named "box".
Quote:
Originally Posted by TB0ne
No animosity at all, ...
All I've gotten from you is animosity. You seem to HATE me for my bad opinion of sendmail. It's as if I've slapped you in the face for rejecting it and you can't tolerate that.
If this were a Microsoft world, I could almost understand because Windows users seem to think there's only one right and approved way to do anything. But the hallmark of Linux is that there's more than one way to do anything and everything, with varying degrees of benefit depending on your objectives. Freedom. Choices, and lots of them. But apparently not in your mind.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.