LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This 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


Reply
  Search this Thread
Old 04-27-2015, 12:08 PM   #16
KenJackson
Member
 
Registered: Jul 2006
Location: Maryland, USA
Distribution: Fedora and others
Posts: 757

Rep: Reputation: 145Reputation: 145

Quote:
Originally Posted by /dev/random View Post
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 View Post
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.
-
 
Old 04-27-2015, 01:34 PM   #17
/dev/random
Member
 
Registered: Aug 2012
Location: Ontario, Canada
Distribution: Slackware 14.2, LFS-current, NetBSD 6.1.3, OpenIndiana
Posts: 319

Rep: Reputation: 112Reputation: 112
Quote:
Originally Posted by KenJackson View Post
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.
 
1 members found this post helpful.
Old 04-27-2015, 01:43 PM   #18
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,634

Rep: Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965
QUO

Quote:
Originally Posted by KenJackson View Post
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.

Last edited by TB0ne; 04-27-2015 at 01:51 PM.
 
Old 04-27-2015, 07:32 PM   #19
KenJackson
Member
 
Registered: Jul 2006
Location: Maryland, USA
Distribution: Fedora and others
Posts: 757

Rep: Reputation: 145Reputation: 145
Quote:
Originally Posted by /dev/random View Post
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.

-
 
Old 04-28-2015, 01:08 AM   #20
descendant_command
Senior Member
 
Registered: Mar 2012
Posts: 1,876

Rep: Reputation: 643Reputation: 643Reputation: 643Reputation: 643Reputation: 643Reputation: 643
Wow.
 
Old 04-28-2015, 02:05 AM   #21
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,912

Rep: Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513
Quote:
Originally Posted by descendant_command View Post
Wow.
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.

Last edited by jpollard; 04-28-2015 at 02:08 AM.
 
Old 04-28-2015, 09:02 AM   #22
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,634

Rep: Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965
Quote:
Originally Posted by descendant_command
Wow.
..and...
Quote:
Originally Posted by jpollard View Post
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 almost POSITIVE I'm getting them, though.
 
Old 05-09-2015, 06:39 AM   #23
kb2tfa
Member
 
Registered: Oct 2006
Location: New Jersey
Distribution: CentOS
Posts: 175

Original Poster
Rep: Reputation: 18
I installed via yum the package 'mailx'

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***

should be sent
 
Old 05-09-2015, 07:13 AM   #24
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,912

Rep: Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513
Technically, that isn't an attachement, but is the body of the message.
 
Old 12-15-2018, 07:42 PM   #25
KenJackson
Member
 
Registered: Jul 2006
Location: Maryland, USA
Distribution: Fedora and others
Posts: 757

Rep: Reputation: 145Reputation: 145
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 View Post
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.
 
1 members found this post helpful.
Old 12-15-2018, 08:24 PM   #26
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.9.2009
Posts: 5,727

Rep: Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211
Quote:
Originally Posted by kb2tfa View Post
I installed via yum the package 'mailx'

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.

Last edited by scasey; 12-15-2018 at 08:31 PM.
 
1 members found this post helpful.
Old 12-16-2018, 09:05 AM   #27
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,634

Rep: Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965
Quote:
Originally Posted by scasey View Post
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.
 
Old 12-16-2018, 10:37 AM   #28
KenJackson
Member
 
Registered: Jul 2006
Location: Maryland, USA
Distribution: Fedora and others
Posts: 757

Rep: Reputation: 145Reputation: 145
Quote:
Originally Posted by TB0ne View Post
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 View Post
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.
 
Old 12-16-2018, 11:19 AM   #29
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,634

Rep: Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965
Quote:
Originally Posted by KenJackson View Post
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:
  1. 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.
  2. 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.
 
Old 12-16-2018, 02:19 PM   #30
KenJackson
Member
 
Registered: Jul 2006
Location: Maryland, USA
Distribution: Fedora and others
Posts: 757

Rep: Reputation: 145Reputation: 145
Quote:
Originally Posted by TB0ne View Post
Very familiar with [ssmtp], ...
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 View Post
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.

I sure hope we're done with this thread.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] How to convert OSX 10.5 Mini Server's Mail & mailboxes to CentOS linux server mail? tstfortruth Linux - Server 4 06-23-2012 01:33 AM
Use an internal mail server to send E-Mails for a non-mail server Glacoras Linux - Server 3 05-03-2011 12:23 PM
mail server migration: howto deliver locally AND forward mail to new server pedrobl Linux - Server 1 01-21-2011 11:12 PM
How to connect linux mail server with the exchange mail server nanuseenu Linux - Newbie 4 03-04-2008 03:37 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 05:07 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration