I'm using gmail gem to send emails and I need track these emails. How can I do this?
I'm trying search the email with the message_id, but it bring all emails from my inbox and I want just the responses of a specific email.
Here is my actual code:
*save email with the message_id*
mail = gmail.deliver(email)
Email.create(:message_id => mail.message_id, :from => user.email,
:to => annotation.to, :body => annotation.content, :title => annotation.title,
:annotation => annotation, :user => user)
*search the mails with message_id*
messages = gmail.inbox.mails(:message_id => email.message_id)
Regards,
Fabrício Ferrari de Campos
you can take Net::IMAP a look.
uid = gmail.conn.uid_search(["HEADER", "Message-ID", "<[email protected]>"])[0]
#=> 103
message = Gmail::Message.new(gmail.inbox, uid)
#=> #<Gmail::Message0x12a72e798 mailbox=INBOX uid=103>
message.subject
#=> "hello world"
message.message_id
#=> "<[email protected]>"
have not find a method can search by message_id.via this way you can get a specific email.
Using the standard gmail gem, this seems to work quite well
messages = gmail.inbox.mails(:query => ['HEADER', 'Message-ID', email.message_id])
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