Forums

ziggx
ziggx
Offline
Resolved
0 votes
Hi there,

I can send a test email from the web page (mail settings), but how do I send an email from a bash script? I have tried:
mail -s 'subject' email-address
but it doesn't work. Please help.

thanks in advance
Ziggy
Sunday, November 15 2020, 10:29 AM
Share this post:
Responses (7)
  • Accepted Answer

    Monday, November 16 2020, 01:44 PM - #Permalink
    Resolved
    0 votes
    I've just tested it on what can be considered a fresh install and it seems to work fine sending the mail to my own e-mail server then to me. I didn't do any particular setting up of the box I was testing on.
    The reply is currently minimized Show
  • Accepted Answer

    ziggx
    ziggx
    Offline
    Monday, November 16 2020, 12:35 PM - #Permalink
    Resolved
    0 votes
    Hi folks,

    Fixed it by installing ssmtp - this works from the command line. No idea why the stock install doesn't work. Thanks to all for your input.

    Cheers
    Ziggx
    The reply is currently minimized Show
  • Accepted Answer

    Sunday, November 15 2020, 03:03 PM - #Permalink
    Resolved
    0 votes
    It looks like mailx is required by app-smtp-core so it should be installed, as should postfix on a default install. The only point I can see of installing the SMTP server is that you get a webconfig screen to start and stop postfix.

    I was wrong about perl. The Mail Settings/Mail Notification app uses a very old version of the Swift PHP mail app, but I don't know beyonf that. I think it has its own mini-smtp server which is why it won't do STARTTLS (until it gets updated).
    The reply is currently minimized Show
  • Accepted Answer

    Sunday, November 15 2020, 02:15 PM - #Permalink
    Resolved
    0 votes
    As Nick indicated you must have a working SMTP server, usually postfix with ClearOS. Also, to use the example command Nick provided you must have the mailx rpm installed. I cannot remember if that rpm is installed by default or whether you must explicitly install it. Use something very similar here to send automated emails from crontab entries at set times.
    You can also

    cat /some/file | mail -s 'Gateway down' nick@example.com
    The reply is currently minimized Show
  • Accepted Answer

    Sunday, November 15 2020, 12:07 PM - #Permalink
    Resolved
    0 votes
    What does it do when it fails?

    You may need to install the SMTP Server app. The Mail Settings app uses some old Perl program to send mail.
    The reply is currently minimized Show
  • Accepted Answer

    ziggx
    ziggx
    Offline
    Sunday, November 15 2020, 11:37 AM - #Permalink
    Resolved
    0 votes
    Hi Nick,

    Unfortunately, that doesn't work - I can't figure what I can send a test message from the web interface but not from a bash script...

    Mysterious...

    Ziggy
    The reply is currently minimized Show
  • Accepted Answer

    Sunday, November 15 2020, 11:21 AM - #Permalink
    Resolved
    0 votes
    echo 'Gateway down' | mail -s 'Gateway down' nick@example.com
    I think you have to have a body (the 'echo' bit of my line) or the mail program hangs waiting for input. It is just possible that you need the SMTP server installed, but I don't think so.
    The reply is currently minimized Show
Your Reply