Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing server response text in Net::SMTPFatalError #19

Closed
papeng opened this issue Nov 30, 2020 · 1 comment
Closed

Missing server response text in Net::SMTPFatalError #19

papeng opened this issue Nov 30, 2020 · 1 comment

Comments

@papeng
Copy link

papeng commented Nov 30, 2020

I noticed that Net::SMTPFatalError exceptions do not contain the full server response error lines.

To test if a SMTP server is rejecting SPF failing messages, I created the following debug snippet with net/smtp:

require 'net/smtp'

smtp = Net::SMTP.new('[REDACTED]', 25)
smtp.set_debug_output STDERR

error_msg = nil

smtp.start() do |smtp_connection|
  begin
    smtp_connection.send_message '', '[email protected]', '[REDACTED]'
  rescue Net::SMTPFatalError => e
    error_msg = e
  end
end

STDERR.puts error_msg

This shows the following SMTP transaction, when the mail is rejected. Notice the two lines containing the SMTP 550 error response.

[...]
<- "MAIL FROM:<[email protected]>\r\n"
-> "550-SPF-check failed:\r\n"
-> "550 example.com does not allow sending mails from [REDACTED]\r\n"
<- "QUIT\r\n"
-> "221 [REDACTED] closing connection\r\n"

But STDERR.puts error_msg only prints the first error line:

550-SPF-check failed:
@tmtm
Copy link
Collaborator

tmtm commented Sep 11, 2021

After #26, you will be abel to:

rescue Net::SMTPFatalError => e
  error_msg = e.response.string
end

@papeng papeng closed this as completed Sep 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants