Questions tagged [mail-gem]
38 questions
13
votes
2 answers
Mail gem. Extract recipient display name and address as separate values
Using the Mail gem (i.e. Rails + ActionMailer), is there a clean way to get the display name of the recipient?
I can get the address with:
mail.to.first
And I can get the formatted display name + address with:
mail.header_fields.select{ |f| f.name…

d11wtq
- 34,788
- 19
- 120
- 195
13
votes
2 answers
Ruby "Mail" gem docs
I can't find the full documentation of the Mail gem https://github.com/mikel/mail
For the documentation, all links are to the main github page, but the readme is far from complete. Is there any alternative to search everything in the source code?

Dan Mazzini
- 1,005
- 10
- 19
6
votes
1 answer
Getting email body without fetching attachments using ruby mail gem
I am trying to fetch the body of gmail using IMAP and ruby mail gem. It works perfectly while I fetch RFC822 field as described in another stack overflow answer.. Fiedl has described the approach very nicely to answer similar question.
This…

Mahesh
- 611
- 9
- 16
5
votes
1 answer
Mail gem not sending emails after upgrading to Rails 5.0.6
I upgraded my Rails app to 5.0.6 from 4.2.5. Now emails are not being sent by the Mail gem. I don't seem to be getting errors. I updated the Mail gem to the latest version with no luck. I am not sure what else to try.
I am running:
Rails 5.0.6
Ruby…

MrAutoIt
- 785
- 6
- 21
5
votes
1 answer
Net::SMTPSyntaxError: 501 Invalid RCPT TO address provided
As I understood I have issue because use not ASCII symbols in emails address
Example:
Notifier.rb
mail(to: "Tamón ÄRUÄ ", subject: "Email subject")
Any advice how I can handle this case? I prefer keep user name in address.

Shaliko Usubov
- 477
- 1
- 4
- 17
4
votes
0 answers
How can I make sure actionmailer & mail gems are only loaded when needed?
I'm trying to reduce my rails 3.2.22 app's memory usage and read that the mail gem eats memory like it's a buffet (http://www.schneems.com/2014/11/07/i-ram-what-i-ram.html). This page says to upgrade mail gem to 2.6.3, but actionmailer 3.2.22 seems…

ckbhodge
- 913
- 2
- 9
- 19
4
votes
1 answer
How to retrieve only unread emails with ruby mail gem?
I am trying to retrieve emails with ruby mail gem, in the examples it says that Mail.last will retrieve the last unread email https://github.com/mikel/mail#getting-emails-from-a-pop-server but it returns just the last email no matter whether it has…

fartagaintuxedo
- 749
- 10
- 28
4
votes
3 answers
Reading email using ruby-mail is not returning the mail body in text format
Im using ruby-mail to read a email.
Everything im getting in proper readable format, except mail body.
Mail body appears as some other encoding format.
My code is :
Mail.defaults do
retriever_method :pop3, :address => "some.email.com",
…

Bhaveshsharma
- 131
- 2
- 4
4
votes
1 answer
ruby 'mikel/mail' reply-to field
I'm parsing an email using the below style
message = Mail.new(body) #where body is the RAW source from the email server
message.subject #=> the subject of the message as a string
message.from #=> shows who the email is from
How would I get a…

Tarang
- 75,157
- 39
- 215
- 276
3
votes
0 answers
Rails 6 + ActionMailbox (mail.decoded) fails with emoji any other unexpected inputs
I'm trying to get plain simple text (no HTML) from email.
It works when I send email with plain text such as "hey this works fine"
It doesn't work when I include an emoji in the email body and it gives the error below in…

Designer
- 1,061
- 1
- 12
- 26
2
votes
1 answer
Invalid delivery method error when trying to use a custom DeliveryMethod in rails
I've built a custom email delivery method for my Rails 4 app:
module CustomDeliverer
class DeliveryMethod
def initialize(options = {})
end
def deliver!(mail)
# method body hidden/not relevant for this question
end
…

Oved D
- 7,132
- 10
- 47
- 69
2
votes
1 answer
message.body.decoded email display is a mess
I'm receiving email into my rails app but setting the email body to message.body.decoded displays the email as a mess. An example is below. Is there a better way to display the email body? Or alternatively is there a way to forward the email to…

Nick5a1
- 917
- 3
- 15
- 28
1
vote
1 answer
Email attachment sent as encoded text
I'm sending an email with one or more attachments, I create the email using Mail gem, here's the code
mail = Mail.new
mail.to = to
mail.subject = subject
mail.body = email_body
mail.content_type = 'text/html'
# attaching a temp file on the rails…

Masroor
- 1,484
- 3
- 14
- 23
1
vote
1 answer
Trying to open / access the text in an attachment to an email using ruby gems
currently trying to write a code to extract text from a text file attachment in an email using ruby gems. Using the 'mail' gem.
this is what the code I found to isolate the body looks like:
mail = Mail.all
mail.each do |current_mail|
mail_object =…

mozartsghost
- 15
- 3
1
vote
0 answers
Send mail with mail and erb gems
I'm trying to send an email using the Mail gem and the ERB gem but I'm getting all the time the this error TypeError Exception: no implicit conversion of Hash into Integer
I read the Mail Gem documentation and the ERB Documentation, and I followed…

bblacker
- 13
- 3