Hello Afan!

Uh.  I had (well, unfortunately not _soo_ really) a girl friend
with – PFFD?  Her name was Nina, and one of her legs was luckily
only a very, very little bit shorter, she only wore special shoes
(and or even only inlays), when we were fifteen.  That are,
autsch, horrifying thirty years, almost!
I hope you're fine!

Afan <[email protected]> wrote:
 |I had a script which called /usr/bin/mail which was working under 
 |Ubuntu 15.10 (It called /usr/bin/mail.mailutils) but after upgrading \
 |to Ubuntu 16.04 - it appears 
 |it was replaced with (as a default mailer) s-nail. 
 |
 |This introduced the following issue: 
 |
 |This command works to send an email:
 |
 |    $cat /tmp/foobar | mail -s 'EXAMPLE SUBJECT' -a /path/to/file/to_\
 |    attach.jpg -c [email protected] [email protected]
 |
 |But when I add that exact same  as a line to a bash file, e.g. 
 |
 |    #!/bin/bash
 |    cat /tmp/foobar | mail -s 'EXAMPLE SUBJECT' -a /path/to/file/to_a\
 |    ttach.jpg -c [email protected] [email protected]
 |
 |This script FAILS and returns the error: 
 |
 |    Alert: "[email protected]" is not a user of this system. 

It seems you set the $USER environment variable to this address,
and i wondered wether the script doesn't use $USER directly and
you were just gentle enough to show us the expansion?

So what happens is that upon startup we will setup and verify some
conditions (with functions like getuid(), getpwuid(), and more,
source code at [1]) in order to be able to provide useful defaults
and - simply - make "the right decisions shall such be necessary".

If you use the -u command line option or set the $USER environment
variable, then we fetch that specified user identity, instead of
deducing the one that is implied by "you" as the person who is
running the script.  The manual says (with hyperlinks: [2]):

   USER Force identification as the given user, i.e., identical to the -u
        command line option.  This variable is only used when it resides
        in the process environment.

And for some reason we are of the opinion that you are
"SOME@ADDRESS", which makes me think it must come from $USER.
Also note that $USER has never been standardized and that the next
S-nail release will start to prefer the variable $LOGNAME (-u ->
$LOGNAME -> $USER it will be), but i have just recently realized
this.

  [1] https://git.sdaoden.eu/cgit/s-nail.git/tree/main.c?h=next#n376
  [2] https://www.sdaoden.eu/code-nail.html#493

 |

 |Some things I've tried in the script to get it to work
 |
 |    #!/bin/bash
 |    cat /tmp/foobar | mail -s 'EXAMPLE SUBJECT' -a /path/to/file/to_a\
 |    ttach.jpg -r real_username -c [email protected] [email protected]

No.  Here you specify the envelope address that will be passed to
the Mail-Transfer-Agent (assuming you don't use SMTP transfer;
manual with links: [3]): so this rather is the user that will be
mentioned in the generated mail, not the user that is running the
script.

 |    #!/bin/bash
 |    cat /tmp/foobar | mail -s 'EXAMPLE SUBJECT' -a /path/to/file/to_a\
 |    ttach.jpg -A real_username -c [email protected] [email protected]

No one more time.  Here you specify an account ([4]), which also
could lead more into the direction of the user of the generated
messages.

Whereas not truly helpful regarding this error and your failed
tries, maybe reading the section "Sending mail"[5] may be a little
bit of a help; then again, it may be overkill to note that the
above examples don't isolate the script invocation from the
current environment, so that, e.g., all the resource files are
loaded?

  $ env LC_ALL=C MAILRC=/dev/null \
    s-nail -n -Ssendwait -Snosave \
      -s ’subject’ -a attachment_file \
      -. "Recipient 1 <recipient1@domain>" recipient2@domain \
    < content_file

And then add all necessary -S options unless it is going the way
you want?

  [3] https://www.sdaoden.eu/code-nail.html#57
  [4] https://www.sdaoden.eu/code-nail.html#38
  [5] https://www.sdaoden.eu/code-nail.html#18

Hope this helps a bit.
I think i have to extend the manual a bit regarding user identity
and accounts, somewhere early, too.  Be warned you will be
credited for that.
Ciao!

--steffen

------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are 
consuming the most bandwidth. Provides multi-vendor support for NetFlow, 
J-Flow, sFlow and other flows. Make informed decisions using capacity 
planning reports. https://ad.doubleclick.net/ddm/clk/305295220;132659582;e
__________________________________
[email protected]

Reply via email to