Back

rails - email name + address,

发布时间: 2022-03-09 01:24:00

refer to: https://stackoverflow.com/questions/957422/rails-actionmailer-format-sender-and-recipient-name-email-address

require 'mail'
address = Mail::Address.new email # ex: "[email protected]"
address.display_name = name.dup   # ex: "John Doe"
# Set the From or Reply-To header to the following:
address.format # returns "John Doe <[email protected]>"

Back