blueimp / aws-smtp-relay

SMTP server to relay emails via Amazon SES or Amazon Pinpoint using IAM roles.
MIT License
75 stars 34 forks source link

mail through telnet fails - 501 invalid FROM parameter #7

Closed craiggenner closed 4 years ago

craiggenner commented 4 years ago

We have an issue where one of our applications is unable to send via the aws-smtp-relay.

We have replicated this following the same steps at https://www.wikihow.com/Send-Email-Using-Telnet

$ docker run --rm -d -p 1025:1025 blueimp/aws-smtp-relay
$ telnet localhost 1025
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
220 03c9d18e7fc6 AWS SMTP Relay ESMTP Service ready
HELO test.example.com
250 03c9d18e7fc6 greets test.example.com
MAIL FROM: craig@example.com
501 5.5.4 Syntax error in parameters or arguments (invalid FROM parameter)

Any ideas what's happening? The above commands work when using against other mail servers and appear to be valid against the RFC.

Thanks

blueimp commented 4 years ago

Hi @craiggenner, following RFC 5321, there are two errors with the MAIL FROM: argument in your example:

  1. The MAIL FROM: header does not accept a space between header name and value.
  2. The MAIL FROM: header requires the mailbox value to be between < and > brackets.

A valid header line would be the following:

MAIL FROM:<craig@example.com>

So yeah, seems like that WikiHow article is unfortunately wrong. I guess the reasons this worked with other SMTP servers is that they might not follow the RFC strictly.

Btw., as listed in the credits, this project makes use of Mark Hale's smtpd project for the SMTP server implementation, which also handles the header parsing.

craiggenner commented 4 years ago

Ah, didn't spot the space in there.

I had tried with the braces (< and >) but not without the space.

I can see the line in the linked project with the regex and the lack of space so thanks for that.

Looks like our (3rd party) software is a fault and the old SMTP server didn't follow the RFC as you say.

Closing with much appreciation for your help. :-)