2

I am trying to send an email to a recipient with an email address starting with a hyphen/dash, e.g. -localpart@example.com

The recipient claims the mail address is correct.

mail.log shows:

postfix/smtpd[26055]: warning: Illegal address syntax from ...[...] in RCPT command: <-localpart@example.com>

I am using Postfix 2.11.3

Any idea how I can send emails to such an address?

2
  • The local part should be valid, although addresses don't commonly start with a hyphen. The obvious check is that there is an invalid character somewhere. Can you test by manually sending to the address on the command line or something like that? Jan 23, 2018 at 9:47
  • Thanks for your reply. I did echo "Just a test" | mail -s Test -- -localpart@example.com (the local part is just letters except for the hyphen and the domain as well - so nothing fancy there). Response is Final-Recipient: rfc822; -localpart@example.com Action: failed Status: 5.1.3 Diagnostic-Code: X-Postfix; bad address syntax
    – Perrschy
    Jan 23, 2018 at 9:51

2 Answers 2

1

You can configure Postfix to accept such addresses with option allow_min_user = yes.

The postconf documentation also explains why the default is to reject such addresses:

Allow a sender or recipient address to have `-' as the first character. By default, this is not allowed, to avoid accidents with software that passes email addresses via the command line. Such software would not be able to distinguish a malicious address from a bona fide command-line option. Although this can be prevented by inserting a "--" option terminator into the command line, this is difficult to enforce consistently and globally.

As of Postfix version 2.5, this feature is implemented by trivial-rewrite(8). With earlier versions this feature was implemented by qmgr(8) and was limited to recipient addresses only.

1

Apparently, postfix has a setting (allow_min_user) prohibiting you from sending mail to addresses starting with a hyphen due to security reasons:

allow_min_user (default: no) Allow a sender or recipient address to have `-' as the first character. By default, this is not allowed, to avoid accidents with software that passes email addresses via the command line...

More here: http://www.postfix.org/postconf.5.html#allow_min_user

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.