Whenever I send an email through my Rails app, in my inbox, the name of the sender is shown as "admin".. The email is admin@... The first part of the domain is shown. Im using Mandrill to send the email. How can I change this name?
Go to the config folder of your emails project and open environment. rb file and add the following line at the bottom of this file. It tells ActionMailer that you want to use the SMTP server. You can also set it to be :sendmail if you are using a Unix-based operating system such as Mac OS X or Linux.
rails generates a mail preview if you use rails g mailer CustomMailer . You will get a file CustomMailerPreview inside spec/mailers/previews folder. Here you can write your method that will call the mailer and it'll generate a preview.
Action Mailer allows you to send emails from your application using mailer classes and views.
If you're using ActionMailer, try below
mail( from: 'Sender Name <[email protected]>', to: 'Receiver Name <[email protected]>', subject: 'Subject' )
If you're using the Mandrill API, you can explicitly set the sender name API call payload
This work for me(Rails):
default( from: "SenderName <[email protected]>", reply_to: "SenderName <[email protected]>" ) def send_mail(email, subject) #body = ...... mail(to: email, subject: subject, body: body, content_type: "text/html") end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With