47

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?

THpubs
  • 7,804
  • 16
  • 68
  • 143

3 Answers3

97

If you're using ActionMailer, try below

mail(
  from: 'Sender Name <sender@example.com>', 
  to: 'Receiver Name <receiver@example.com>', 
  subject: 'Subject'
)

If you're using the Mandrill API, you can explicitly set the sender name API call payload

iconoclast
  • 21,213
  • 15
  • 102
  • 138
membLoper
  • 1,972
  • 19
  • 21
19

This work for me(Rails):

default(

   from: "SenderName <hola@udocz.com>",
   reply_to: "SenderName <hola@udocz.com>"

)

def send_mail(email, subject)

   #body = ......

   mail(to: email, subject: subject, body: body, content_type: "text/html")

end
Cookie Ninja
  • 1,156
  • 15
  • 29
3

I've used this solution from the ActionMailer guide and it works perfectly.

class AdminMailer < ApplicationMailer
    default from: email_address_with_name('admin@example.com', 'Admin Name')
end
inmydelorean
  • 448
  • 6
  • 13