Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can we set the name of the email sender in Rails Mailer?

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?

like image 310
THpubs Avatar asked Dec 28 '13 05:12

THpubs


People also ask

How do I use SMTP in Ruby on Rails?

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.

How do you preview Mailer in Rails?

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.

What is ActionMailer?

Action Mailer allows you to send emails from your application using mailer classes and views.


Video Answer


2 Answers

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

like image 144
membLoper Avatar answered Sep 29 '22 10:09

membLoper


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 
like image 37
Ricardo Garcia Izasiga Avatar answered Sep 29 '22 09:09

Ricardo Garcia Izasiga