LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Transition from UNIX to Linux and in sendmail purgatory (https://www.linuxquestions.org/questions/linux-newbie-8/transition-from-unix-to-linux-and-in-sendmail-purgatory-4175602717/)

rip73 03-28-2017 12:07 PM

Transition from UNIX to Linux and in sendmail purgatory
 
Good afternoon,

New to Linux (since Monday) and have encountered a few things with sendmail that need some solutions to.

Bit of background. We took our same sendmail construct from UNIX in LINUX. Basic code structure is as follows
------------
mpack -s "Morning Report" -d <report text body> -o <report tempfile> morningspreadsheet.xls

/usr/sbin/sendmail -f <sender address> <recipient address> < <report tempfile>
-------------

It will send the email but we have noticed the following

1.) the "To" tag is currently always blank
2.) the "From" does not show a from name but it shows the name of the process that is running with the recipient address. For example "root (personwhoworkshere@thiscompany.com)" instead of "My Name (personwhoworkshere@thiscompany.com)"

Is there any means of working with the current options to get the "To" tag to show and fix the name of the "From"? So far we have deduced that we will have to create a text with this information in it in order to do. However, if there is a way to do this without having to update a few hundred text files that would be great.

Thanks!

RIP

RandomTroll 03-28-2017 03:41 PM

sendmail should behave the same in Linux as it does in Unix: the source is the same.

The sendmail command you specify doesn't set a recipient in the header; use the -t switch.
Use the -F switch to set the sender's 'full name'. Different e-mail clients show different 'from' for the same message. Different recipients are seeing it differently.

Perhaps you have a different sendmail.cf - though I don't know what differences would cause the difference you report.

bathory 03-28-2017 04:07 PM

Welcome to Linux and LQ,

You should specify your distro, so we could help you better. Depending on distro, if sendmail is not installed, the sendmail command is linked to a compatibility binary of the installed smtp server s/w (like postfix, qmail, exim etc).
So while for the real sendmail, the -f switch is correct and it should work in your example, in the compatibility binaries it may not work.

That said, you can use mutt, or mail/mailx to do your job. E.g:
Code:

EMAIL=<sender address> mutt -s "Morning Report" <recipient address> < <report tempfile>
Regards

rip73 03-28-2017 04:58 PM

Quote:

Originally Posted by RandomTroll (Post 5689452)
sendmail should behave the same in Linux as it does in Unix: the source is the same.

The sendmail command you specify doesn't set a recipient in the header; use the -t switch.
Use the -F switch to set the sender's 'full name'. Different e-mail clients show different 'from' for the same message. Different recipients are seeing it differently.

Perhaps you have a different sendmail.cf - though I don't know what differences would cause the difference you report.

Thank you for your response. Perhaps I am not reading the man page correctly but the -t options reads like it will pull the "to:" from a file. With the sendmail we did not have that in the text since we could include it as an option. We are trying to not have to update each of the files to include the "From:" and "To:" information if possible.

rip73 03-28-2017 05:00 PM

Quote:

Originally Posted by bathory (Post 5689467)
Welcome to Linux and LQ,

You should specify your distro, so we could help you better. Depending on distro, if sendmail is not installed, the sendmail command is linked to a compatibility binary of the installed smtp server s/w (like postfix, qmail, exim etc).
So while for the real sendmail, the -f switch is correct and it should work in your example, in the compatibility binaries it may not work.

That said, you can use mutt, or mail/mailx to do your job. E.g:
Code:

EMAIL=<sender address> mutt -s "Morning Report" <recipient address> < <report tempfile>
Regards

Question, for using mail/mailx. I thought you would have to have a file with the To and From in order to use the option that would extract them. Is that not the case?

RandomTroll 03-28-2017 10:06 PM

Whoops! You have read the man page correctly. I set up programs to do this automatically years ago and forgot what the -t switch does. Sorry.

I use echo to prepend recipients and subject to a dummy file, concatenate the message to that dummy file, then send it with -t.
For example:
Code:


echo -e "from:  scientist@entomology.com\nto:  Banana@fruit.com \nsubject:  Fruit flies\n\n" > DummyFile
cat TextOfMessage >> DummyFile
sendmail -t < DummyFile
rm DummyFile

Mr/Ms Bathory makes a valuable observation that other SMTP servers partially-emulate sendmail, that you may not have sendmail on your new system.

bathory 03-29-2017 02:02 AM

Quote:

Originally Posted by rip73 (Post 5689494)
Question, for using mail/mailx. I thought you would have to have a file with the To and From in order to use the option that would extract them. Is that not the case?

Nope. You can give the From address at command line.
But again it depends on distro, that's why I've asked you to tells us the Linux distribution you're running.
Anyway if you don't want to use mutt as in my example above, read the manpage of mail/nail/mailx (whatever your distro uses) to find the correct options.

Regards

chrism01 03-30-2017 02:33 AM

I agree with Bathory, tell us your distro.
A lot of modern distros have moved on eg RHEL derived systems have moved on to postfix.
Even if if you then install sendmail, it might not actually be what's running.

rip73 03-30-2017 12:58 PM

Quote:

Originally Posted by chrism01 (Post 5690190)
i agree with bathory, tell us your distro.
A lot of modern distros have moved on eg rhel derived systems have moved on to postfix.
Even if if you then install sendmail, it might not actually be what's running.

rhel 7

bathory 03-30-2017 01:25 PM

Quote:

Originally Posted by rip73 (Post 5690413)
rhel 7

So what gives:
Quote:

ls -l /etc/alternatives/mta
Did you consider using mutt for your task?

rip73 03-30-2017 01:27 PM

Quote:

Originally Posted by bathory (Post 5690426)
So what gives:

Did you consider using mutt for your task?

We are open at this point but we were trying to not have to rewrite a bunch of programs if we do not have to. Is there something with RHEL 7 and sendmail not being compatible? Is there something with postfix that would help to keep using sendmail?

RandomTroll 03-30-2017 01:34 PM

There's no reason you can't install sendmail. I customize sendmail.mc so I build my own. It's not onerous.

rip73 03-30-2017 02:08 PM

Quote:

Originally Posted by RandomTroll (Post 5690429)
There's no reason you can't install sendmail. I customize sendmail.mc so I build my own. It's not onerous.

We have sendmail installed but it seems to not work consistently. Sometimes not at all.


All times are GMT -5. The time now is 02:37 AM.