Vm: After setup SMTP relay; errors "mail: invalid option"

Created on 19 Nov 2020  Â·  6Comments  Â·  Source: nextcloud/vm

Steps to reproduce

  1. Download the nextcloud VMware / VirtualBox (.OVA) Nextcloud VM Pre-installed – 40 GB v20.0.1
  2. Run through a standard install, using an SMTP mail relay
  3. Initial test works to SMTP relay
  4. Every subsequent "Sending" on the console shows an error

Expected behaviour

Mail sent after the test email received is also received

Actual behaviour

No mail sent during setup is received, except initial test.
Every time the setup says it is sending mail there is an error:

mail: invalid option -- '-'

Server configuration

Nextcloud server version: Nextcloud 20.0.2 (although installer was 20.0.1 and it updated)

Server OS Ubuntu server

How did you install the VM? Released version

Network

Do you use DHCP? Yes

Is port 80 and/or 443 open? Yes

Logs / Screenshots

Received test
nc-mail-test-worked

On of the many exact same errors during setup sending mail
nc-send-error

Log file (/var/log/nextcloud/nextcloud.log)

https://0bin.net/paste/hvOTicSf#dqg4206hr85qg7tXoC7o32vqpP1151EoX7V+I6rgr4p

Installation log (command output)

N/A here

bug

All 6 comments

cc @szaimen

@lantrix I can unfortunately not reproduce this. Have you tried to reinstall it? Maybe this fixes the problem...

Could you please post your mail logs:
/var/log/msmtp

Also it would be interesting what is inside
/etc/mail.rc

Thanks!

Thanks @szaimen I'll reinstall it, and see if it happens again.
I'll also grab a copy of the logs if it does again.

Did the reinstall of 20.0.2 and same problem exactly. Into email works, rest error with:

mail: invalid option -- '-'
usage: mail [-dEIinv] [-a header] [-b bcc-addr] [-c cc-addr] [-r from-addr] [-s subject] [--] to-addr ...
       mail [-dEIiNnv] -f [name]
       mail [-dEIiNnv] [-u user]

/var/log/msmtp is:

mail: /usr/bin/msmtp -t: No such file or directory
Can't send mail: sendmail process failed with error code 1
Dec 06 22:49:15 host=smtp.pobox.com tls=on auth=on [email protected] [email protected] [email protected] mailsize=1119 smtpstatus=250 smtpmsg='250 2.0.0 Ok: queued as 6C1E89EEA3' exitcode=EX_OK

/etc/mail.rc is:

set sendmail="/usr/bin/msmtp"

I've manually imported the lib.sh into a root session to test send_mail "subject" "message" function in the library.

Same error

root@cloud:~# send_mail "subject" "text"
Sending 'subject' to [email protected]
mail: invalid option -- '-'
usage: mail [-dEIinv] [-a header] [-b bcc-addr] [-c cc-addr] [-r from-addr] [-s subject] [--] to-addr ...
       mail [-dEIiNnv] -f [name]
       mail [-dEIiNnv] [-u user]

Breaking down the function and running it manually, this line is the one failing:

root@cloud:~# RECIPIENT=$(grep "recipient=" /etc/msmtprc)
root@cloud:~# RECIPIENT="${RECIPIENT##*recipient=}"
root@cloud:~# echo -e "test message" | mail --subject "NcVM - test subject" "$RECIPIENT"
mail: invalid option -- '-'
usage: mail [-dEIinv] [-a header] [-b bcc-addr] [-c cc-addr] [-r from-addr] [-s subject] [--] to-addr ...
       mail [-dEIiNnv] -f [name]
       mail [-dEIiNnv] [-u user]

This DOES work:

echo -e "test message" | mail -s "NcVM - test subject" "$RECIPIENT"

The reason the welcome email works is it already uses -s in the script smtp-mail.sh

Was this page helpful?
0 / 5 - 0 ratings

Related issues

wouterVE picture wouterVE  Â·  4Comments

szaimen picture szaimen  Â·  6Comments

mr-manuel picture mr-manuel  Â·  6Comments

dseeker picture dseeker  Â·  4Comments

enoch85 picture enoch85  Â·  5Comments