ActionMailer: SMTP From address may not be blank / Net::SMTPAuthenticationError Ruby / Rails Origin: Application & API Last updated 5 Nov 2026

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.

Exact message you may see 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)
Seen on: Ruby 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 from address 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

  1. default from: "noreply@example.com" in the mailer
  2. Configure smtp_settings and credentials via Rails.application.credentials
  3. Test with ActionMailer::Base.mail(...).deliver_now in the console

Detailed fix by platform

Rails

  1. 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

  1. from — Set?
  2. SMTP — Settings correct?
  3. 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:

Where this error sits

Origin: Application & API. Errors that are often confused with or caused by this one (click to open):

530 5.7.0 Authentication Required — SMTP: 530 5.7.0 Must issue a STARTTLS command first / 530 5.7.1 Authentication required (Email / SMTP)530 5.7.0 Authenticat…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 (Email / SMTP)535 5.7.8 Username an…ActiveRecord::AssociationTypeMismatch — Rails: ActiveRecord::AssociationTypeMismatch: User(#1234) expected, got "42" which is an instance of String(#5678) (Ruby / Rails)ActiveRecord::Associa…ActiveRecord::ConnectionNotEstablished — Rails: ActiveRecord::ConnectionNotEstablished: No connection pool for 'ActiveRecord::Base' found (Ruby / Rails)ActiveRecord::Connect…ActiveRecord::Deadlocked: PG::TRDeadlockDetected — Rails: ActiveRecord::Deadlocked: PG::TRDeadlockDetected: ERROR: deadlock detected (Ruby / Rails)ActiveRecord::Deadloc…ActiveRecord::IrreversibleMigration — Rails: ActiveRecord::IrreversibleMigration — This migration uses remove_column without a type; db:rollback can't reverse it (Ruby / Rails)ActiveRecord::Irrever…PG::ConnectionBad: could not connect to server — Rails: PG::ConnectionBad: could not connect to server: Connection refused. Is the server running on host "localhost" (127.0.0.1) and accepting TCP/IP connections on port 5432? (Ruby / Rails)PG::ConnectionBad: co…ActionMai…

Explore the map of this error Full error map →

🧠 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.