I send email from my domain using postfix without any issue. The problem is that when I send same email using a Rails application with same sender address, the message goes to spam folder in Gmail. I've tested it with and without Message-ID option in the mailer class:
default "Message-ID" => "#{Digest::SHA2.hexdigest(Time.now.to_i.to_s)}@mydomail.com"
This is my SMTP configurations:
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
address: "127.0.0.1",
port: 25,
enable_starttls_auto: false
}
config.action_mailer.perform_deliveries = true
What configuration option I've missed that caused my emails to go to the spam folder?
It was a Postfix + DNS problem. Emails goes to spam folder in Gmail that means everything is ok with Rails. After I checked the Postfix main.cf
noticed that the host
value was srv1.example.com
and SPF record in DNS was example.com
.