Page 1 of 3 123 LastLast
Results 1 to 10 of 27

Thread: sending email to web mail or local admin

  1. #1

    Default sending email to web mail or local admin

    I need to be able send web-mail and send to local admin with an attachment. I'v done some research and found various commands.

    mail
    mailx
    sendmail
    ...

    Which one(s) are common to distros and allow both local and webmail? Preferred, no additional installs and no system cfg setup? Please show recommended formatting based on following code.


    Current line (not tested):

    Code:
     cat /var/log/VirusVault/VirusFoundZipSendEmailBody.cfg | mail -r "$Zip_Send_Email" -s "$VirusFoundZipSendEmailSubject" "$VirusFoundZipSendEmailSubject"

    Thanks...

  2. #2
    Join Date
    Jan 2014
    Location
    Erlangen
    Posts
    3,845

    Default Re: sending email to web mail or local admin

    Quote Originally Posted by lord_valarian View Post
    I need to be able send web-mail and send to local admin with an attachment. I'v done some research and found various commands.

    mail
    mailx
    sendmail
    ...

    Which one(s) are common to distros and allow both local and webmail? Preferred, no additional installs and no system cfg setup? Please show recommended formatting based on following code.


    Current line (not tested):

    Code:
     cat /var/log/VirusVault/VirusFoundZipSendEmailBody.cfg | mail -r "$Zip_Send_Email" -s "$VirusFoundZipSendEmailSubject" "$VirusFoundZipSendEmailSubject"

    Thanks...
    Some years ago I configured postfix / fetchmail: https://karlmistelberger.wordpress.c...nsuse-desktop/ See also: https://www.binarytides.com/linux-mailx-command/
    i7-6700K (2016), i5-8250U (2018), AMD Ryzen 5 3400G (2020), 5600X (2022) openSUSE Tumbleweed, KDE Plasma

  3. #3
    Join Date
    Oct 2014
    Location
    Rotterdam
    Posts
    768

    Default Re: sending email to web mail or local admin

    On a normal system mail is setup as the default mailer:

    Code:
    > ls -l /usr/bin/mail 
    lrwxrwxrwx 1 root root 22 Jan  7 20:46 /usr/bin/mail -> /etc/alternatives/mail
    So if I want something that works common to distros I would opt for mail.

  4. #4

    Default Re: sending email to web mail or local admin

    Quote Originally Posted by marel View Post
    On a normal system mail is setup as the default mailer:

    Code:
    > ls -l /usr/bin/mail 
    lrwxrwxrwx 1 root root 22 Jan  7 20:46 /usr/bin/mail -> /etc/alternatives/mail
    So if I want something that works common to distros I would opt for mail.
    Oops, buggy line. Here the section of code. Note, 'f' option sends to folder.

    Code:
              elif [[ "$Parm_Options" == *'m'* ]]; then
                   if [[ "$Parm_Folder_Email" == '@' ]]; then
                        Zip_Send_Email="$VirusFoundZipSendEmailTo"
                   else
                        Zip_Send_Email="$Parm_Folder_Email"
                   fi
                   printf "To       -> %s\n" "$Zip_Send_Email"
                   printf "From     -> %s\n" "$VirusFoundZipSendEmailFrom"
                   printf "Subject  -> %s\n" "$VirusFoundZipSendEmailSubject"
                   printf "Body     -> \n"
                   cat /var/log/VirusVault/VirusFoundZipSendEmailBody.cfg
                   printf "Sending Email...\n"
                   cat /var/log/VirusVault/VirusFoundZipSendEmailBody.cfg | mail -r "$Zip_Send_Email" -s "$VirusFoundZipSendEmailSubject" "$Zip_Send_Email"
              fi
    Mail is the local users tool only? Do I need to start a mail server? Then shut it down to get it to send to a webmail adress?


    Code:
    # ls -l /usr/bin/mail 
    lrwxrwxrwx 1 root root 5 Dec  1 08:24 /usr/bin/mail -> mailx
    #ls -l /etc/alternatives/mail 
    ls: cannot access '/etc/alternatives/mail': No such file or directory
    

  5. #5

    Default Re: sending email to web mail or local admin

    Quote Originally Posted by karlmistelberger View Post
    One page is in german, I think that's the language. I can read some of it.

  6. #6
    Join Date
    Jan 2014
    Location
    Erlangen
    Posts
    3,845

    Default Re: sending email to web mail or local admin

    Quote Originally Posted by lord_valarian View Post
    Oops, buggy line. Here the section of code. Note, 'f' option sends to folder.

    Code:
              elif [[ "$Parm_Options" == *'m'* ]]; then
                   if [[ "$Parm_Folder_Email" == '@' ]]; then
                        Zip_Send_Email="$VirusFoundZipSendEmailTo"
                   else
                        Zip_Send_Email="$Parm_Folder_Email"
                   fi
                   printf "To       -> %s\n" "$Zip_Send_Email"
                   printf "From     -> %s\n" "$VirusFoundZipSendEmailFrom"
                   printf "Subject  -> %s\n" "$VirusFoundZipSendEmailSubject"
                   printf "Body     -> \n"
                   cat /var/log/VirusVault/VirusFoundZipSendEmailBody.cfg
                   printf "Sending Email...\n"
                   cat /var/log/VirusVault/VirusFoundZipSendEmailBody.cfg | mail -r "$Zip_Send_Email" -s "$VirusFoundZipSendEmailSubject" "$Zip_Send_Email"
              fi
    Mail is the local users tool only? Do I need to start a mail server? Then shut it down to get it to send to a webmail adress?


    Code:
    # ls -l /usr/bin/mail 
    lrwxrwxrwx 1 root root 5 Dec  1 08:24 /usr/bin/mail -> mailx
    #ls -l /etc/alternatives/mail 
    ls: cannot access '/etc/alternatives/mail': No such file or directory
    
    What most distributions use:
    Code:
    erlangen:~ # readlink -f /usr/bin/mail 
    /usr/bin/mailx 
    erlangen:~ # rpm -qf /usr/bin/mailx        
    mailx-12.5-32.2.x86_64 
    erlangen:~ # zypper if mailx           
    Loading repository data... 
    Reading installed packages... 
    
    
    Information for package mailx: 
    ------------------------------ 
    Repository     : Haupt-Repository (OSS) 
    Name           : mailx 
    Version        : 12.5-32.2 
    Arch           : x86_64 
    Vendor         : openSUSE 
    Installed Size : 576.5 KiB 
    Installed      : Yes 
    Status         : up-to-date 
    Source package : mailx-12.5-32.2.src 
    Summary        : A MIME-Capable Implementation of the mailx Command 
    Description    :  
        Nail is a mail user agent derived from Berkeley Mail 8.1.  It is 
        intended to provide the functionality of the POSIX.2 mailx command with 
        additional support for MIME messages, POP3, and SMTP.  In recent system 
        environments, nail is Unicode/UTF-8 capable.  Further, it contains some 
        minor enhancements like the ability to set a "From:" address. 
    
    erlangen:~ #
    Code:
    erlangen:~ # zypper if postfix 
    Loading repository data... 
    Reading installed packages... 
    
    
    Information for package postfix: 
    -------------------------------- 
    Repository     : Haupt-Repository (OSS) 
    Name           : postfix 
    Version        : 3.6.2-7.3 
    Arch           : x86_64 
    Vendor         : openSUSE 
    Installed Size : 3.4 MiB 
    Installed      : Yes 
    Status         : up-to-date 
    Source package : postfix-3.6.2-7.3.src 
    Summary        : A fast, secure, and flexible mailer 
    Description    :  
        Postfix aims to be an alternative to the widely-used sendmail program. 
    
    erlangen:~ #
    Configuring postfix using "yast2 mail" takes a few minutes at most. But that is not an option for users who want to tinker.
    i7-6700K (2016), i5-8250U (2018), AMD Ryzen 5 3400G (2020), 5600X (2022) openSUSE Tumbleweed, KDE Plasma

  7. #7

    Default Re: sending email to web mail or local admin

    Note: mail or mailx produces no output to debug. I tried it with local_username and I think it worked.

  8. #8
    Join Date
    Jan 2014
    Location
    Erlangen
    Posts
    3,845

    Default Re: sending email to web mail or local admin

    Quote Originally Posted by lord_valarian View Post
    Note: mail or mailx produces no output to debug. I tried it with local_username and I think it worked.
    You may try "mailx -d".
    i7-6700K (2016), i5-8250U (2018), AMD Ryzen 5 3400G (2020), 5600X (2022) openSUSE Tumbleweed, KDE Plasma

  9. #9
    Join Date
    Jan 2014
    Location
    Erlangen
    Posts
    3,845

    Default Re: sending email to web mail or local admin

    mailx -v sends a comprehensive message:
    Code:
    Mail Delivery Status Report
    
    Von:    Mail Delivery System <MAILER-DAEMON@localhost>
    An:    Ich
    Datum:    24.01.22 07:24
    This is the mail system at host localhost.
    
    Enclosed is the mail delivery report that you requested.
    
                       The mail system
    
    <karl.mistelberger@....>: delivery via
        mail.mnet-online.de[62.245.150.229]:25: 250 2.0.0 from
        MTA(smtp:[frontend01.mail.intern.m-online.net]:10025): 250 2.0.0 Ok: queued
        as 4Jj0MW4kDcz1qqkB
    Unbenannt
    Delivery report
    Return-Path: <karl.....>
    Received: by localhost (Postfix, from userid 1000)
            id B8D16542DC; Mon, 24 Jan 2022 07:24:54 +0100 (CET)
    Date: Mon, 24 Jan 2022 07:24:54 +0100
    From: karl.....
    To: karl....
    Subject: test
    Message-ID: <61ee4636.SbdEG3d6UXRw6TUg%karl.....>
    User-Agent: Heirloom mailx 12.5 7/5/10
    MIME-Version: 1.0
    Content-Type: text/plain; charset=us-ascii
    Content-Transfer-Encoding: 7bit
    i7-6700K (2016), i5-8250U (2018), AMD Ryzen 5 3400G (2020), 5600X (2022) openSUSE Tumbleweed, KDE Plasma

  10. #10

    Default Re: sending email to web mail or local admin

    Quote Originally Posted by karlmistelberger View Post
    You may try "mailx -d".
    email address hidden, but valid

    Code:
    # mailx --help 
    mailx: illegal option -- - 
    Usage: mailx [-BDFintv~] [-s subject] [-a attachment ] [-c cc-addr] [-b bcc-addr] 
                 [-r from-addr] [-h hops] [-A account] [-R reply-addr] [-S option] to-addr ... 
           mailx [-BDeHiInNRv~] [-T name] [-A account] -f [name] [-S option] 
           mailx [-BDeinNRv~] [-A account] [-u user] [-S option] 
    Is it reply to or from address that I need to use?

    Code:
    cat /var/log/VirusVault/VirusFoundZipSendEmailBody.cfg | mailx -d -r "$Zip_Send_Email" -s "$VirusFoundZipSendEmailSubject" "$Zip_Send_Email"
    Code:
    Sending Email...
    user = root, homedir = /root
    Sendmail arguments: "sendmail" "-i" "-r" "username@server.com" "--" "username@server.com"
    https://www.man7.org/linux/man-pages/man1/mailx.1p.html

    Code:
    cat /var/log/VirusVault/VirusFoundZipSendEmailBody.cfg | mailx -v -r "$Zip_Send_Email" -s "$VirusFoundZipSendEmailSubject" "$Zip_Send_Email"
    Code:
    ______________________________________________________________________________
    Sending Email...
    Mail Delivery Status Report will be mailed to <username@server.com>.
    Nothing yet... Thanks.

Page 1 of 3 123 LastLast

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •