Menu

MacOS cannot use /usr/bin/mail to send email

Help
Nap
2020-07-15
2020-07-15
  • Nap

    Nap - 2020-07-15

    [MacOS, Apache 2.4, PHP 7.3.11, Wikindx (download a couple days ago), MariaDB 10.4.13]

    I'm configuring the mail settings on my server and want to use /usr/bin/mail.
    It works from the command line for both the Apache user (_www) and my own userID but I get an error "Could not execute: /user/bin/mail" when I run the mail test function in WikiNDX.

    "/usr/bin/mail" has permissions that allow execution by others (as per my comments above), so I'm wondering if Apache's httpd.conf needs to be configured to allow access to that folder.

    Any suggestions?

        ---[CONFIGURATION]------------------------------------------------------
    
        WIKINDX_MAIL_BACKEND = sendmail
        WIKINDX_MAIL_FROM = user@server.tld
        WIKINDX_MAIL_REPLYTO = noreply@noreply.org
        WIKINDX_MAIL_RETURN_PATH = 
        WIKINDX_MAIL_SENDMAIL_PATH = /usr/bin/mail
        WIKINDX_MAIL_SMTP_AUTH = 0
        WIKINDX_MAIL_SMTP_ENCRYPT = none
        WIKINDX_MAIL_SMTP_PASSWORD = [credentials hidden]
        WIKINDX_MAIL_SMTP_PERSIST = 0
        WIKINDX_MAIL_SMTP_PORT = 25
        WIKINDX_MAIL_SMTP_SERVER = localhost
        WIKINDX_MAIL_SMTP_USERNAME = 
        WIKINDX_MAIL_USE = 1
    
        ---[LOG]----------------------------------------------------------------
    
        2020-07-15 07:27:12 Could not execute: /usr/bin/mail
    
    
        Could not execute: /usr/bin/mail
    
     
  • Nap

    Nap - 2020-07-15

    Thanks Stephane, but I'm able to send mail from the CLI using sudo -u _www /usr/bin/mail -s "Test" user@domain.tld < ~/index.php. The mail is delivered to my email.

    This also works from within Bash scripts. Why won't it work from PHP?

    I don't want to use a 3rd party server, and my server is already able to send mail using /usr/bin/mail. My mail server, where I'm receiving the email, has port 25 open, so there's no need to involve TSL or StartTSL.

     

    Last edit: Nap 2020-07-15
    • Stéphane Aulery

      You should never do sudo to send a mail. if you do, it's not well configured. All mail command are not the same on all Unices and mail is not a mail server but a mail client.

      PHPMailer have been made to use a regular sendmail command which is a wrapper to talk to a mail server on Unices, or talk to a regular SMTP server (local or remote) .

      Don't try to emulate the sendmail command with the mail command. It's doomed.

       
      • Nap

        Nap - 2020-07-15

        I'm using sudo there to switch to the Apache user. It's not needed to send mail from my own account.

         
        • Stéphane Aulery

          This does not change the rest of my explanation.

           
  • Mark Grimshaw

    Mark Grimshaw - 2020-07-15

    Hi Nap,

    It's a long time since I've played around with Linux and command line . . .

    However, looking at this:
    https://www.binarytides.com/linux-mail-command-examples/

    it seems that to send the mail command on one line without following the /mail interactive prompts, you need to supply further parameters (which is what you do in your command line example). WIKINDX won't supply these extra parameters because it doesn't expect to use /mail. As Stéphane says, the PHPMailer interface WIKINDX uses is set up to use sendmail (as /mail itself does).

    I think you need to enter the path in WIKINDX for sendmail.

    Regards,

    Mark

     
  • Nap

    Nap - 2020-07-15

    Thanks Mark. I appreciate Stephane's and your responses.

    The link you referred me to shows exactly how I'm using /usr/bin/mail.
    I've tried setting the "SendMail Path" to usr/bin/mail but it's not working with SMTP Server set to either SMTP or SendMail.

    From Stephane's comments, I gather that WIKINDX uses PHPMailer, which is of course intended for use in the wild. Our use case is a computer in our lab which is behind our university's VPN.

    So, I gather, from the feedback that WIKINDX wasn't mean to be used like I'm wanting to.

     
  • Mark Grimshaw

    Mark Grimshaw - 2020-07-15

    Hi Nap,

    You must set the sendmail path to /usr/sbin/sendmail or wherever sendmail is located (NOT mail). And, of course, SMTP server should be set to 'Sendmail'. If I remember correctly, the path can even be left blank and PHPMailer will try to find sendmail. Best to explicitly set it.

    sendmail is the actual program that does the work regardless of whether it is accessed through WIKINDX/PHPMailer or usr/bin/mail both of which are just frontends to sendmail.

    From the link I posted earlier:
    mail command -> /usr/sbin/sendmail -> local MTA (smtp server) -> recipient MTA (and Inbox)

    Regards,

    Mark

     
  • Nap

    Nap - 2020-07-15

    Cheers Mark. Though it didn't work before, /usr/sbin/sendmail in the path field works now. Maybe I hadn't press "Proceed" before I attempted the test.

     
  • Mark Grimshaw

    Mark Grimshaw - 2020-07-15

    Glad it's working now Nap. The other common error is to do /usr/bin/sendmail instead of /usr/sbin/sendmail.

    Is your wikindx publicly available for read only? I like seeing where our work is used . . .

    Regards,

    Mark

     
  • Nap

    Nap - 2020-07-15

    I'm afraid it is not since it's behind the Uni's VPN. But if you want to see it, I can host a Jitsi video conference and screen share with you.

     
  • Nap

    Nap - 2020-07-15

    Send me an email to Napoleon_BlownApart using the ABMS.net.au domain.

     
  • Nap

    Nap - 2020-07-15

    Mark, I replied from a different email account to the one mentioned above. Did you get my mail?

     

Log in to post a comment.