Rails: ArgumentError: SMTP From address may not be blank: nil / Net::SMTPAuthenticationError: 535 5.7.8 Username and Password not accepted
Rails mail delivery failed — missing from, wrong SMTP settings, or rejected credentials.
ArgumentError: SMTP From address may not be blank: nilArgumentError (SMTP To address may not be blank: [])Net::SMTPAuthenticationError: 535-5.7.8 Username and Password not acceptedErrno::ECONNREFUSED: Connection refused - connect(2) for "localhost" port 25Net::OpenTimeout: execution expired (smtp) Meaning
Set default from: "noreply@example.com" in the mailer or ApplicationMailer, configure config.action_mailer.smtp_settings (address, port 587, enable_starttls_auto, user, password), and use app passwords/OAuth for Gmail. raise_delivery_errors = true in development to see failures.
Common causes
- No
fromaddress configured - Wrong SMTP host/port/TLS
- Credentials missing (env vars not set)
- Gmail needs app password
- delivery_method not set (default :smtp to localhost)
⚡ Quick fix
default from: "noreply@example.com"in the mailer- Configure
smtp_settingsand credentials viaRails.application.credentials - Test with
ActionMailer::Base.mail(...).deliver_nowin the console
Detailed fix by platform
Rails
config.action_mailer.smtp_settings = { address: "smtp.example.com", port: 587, user_name: ENV["SMTP_USER"], password: ENV["SMTP_PASS"], authentication: :plain, enable_starttls_auto: true }
How to diagnose
- from — Set?
- SMTP — Settings correct?
- Auth — App password?
🔧 Still not fixed?
Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:
Similar errors
- 530 5.7.0 Authentication Required SMTP: 530 5.7.0 Must issue a STARTTLS command first / 530 5.7.1 Authentication required
- 535 5.7.8 Username and Password not accepted SMTP: 535-5.7.8 Username and Password not accepted. Learn more at https://support.google.com/mail/?p=BadCredentials
- ActiveRecord::AssociationTypeMismatch Rails: ActiveRecord::AssociationTypeMismatch: User(#1234) expected, got "42" which is an instance of String(#5678)
Most viewed in Ruby / Rails
- ActiveRecord::PendingMigrationError Rails: ActiveRecord::PendingMigrationError — Migrations are pending. To resolve this issue, run: bin/rails db:migrate
- undefined method for nil Ruby: NoMethodError: undefined method `x' for nil (nil:NilClass)
- ActionController::InvalidAuthenticityToken Rails: ActionController::InvalidAuthenticityToken (Can't verify CSRF token authenticity)
Other ways to find it
Where this error sits
Origin: Application & API. Errors that are often confused with or caused by this one (click to open):
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
💬 What worked for others
No tips yet — did something else fix this for you?
Share what worked for you
Tips are checked by an editor before they appear. Links are removed.
Report a correction or suggest an improvement
Last updated 5 Nov 2026