Fab*_*cio 6 ruby gmail tracking
我正在使用gmail gem发送电子邮件,我需要跟踪这些电子邮件.我怎样才能做到这一点?
我正在尝试使用message_id搜索电子邮件,但它会从我的收件箱中收集所有电子邮件,我只想要特定电子邮件的回复.
这是我的实际代码:
*使用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)
Run Code Online (Sandbox Code Playgroud)
*使用message_id搜索邮件*
messages = gmail.inbox.mails(:message_id => email.message_id)
Run Code Online (Sandbox Code Playgroud)
问候,
FabrícioFerraride Campos
小智 3
你可以看看Net::IMAP。
uid = gmail.conn.uid_search(["HEADER", "Message-ID", "<324820.440351247482145930.JavaMail.coremail@bj163app31.163.com>"])[0]
#=> 103
message = Gmail::Message.new(gmail.inbox, uid)
#=> #<Gmail::Message0x12a72e798 mailbox=INBOX uid=103>
message.subject
#=> "hello world"
message.message_id
#=> "<324820.440351247482145930.JavaMail.coremail@bj163app31.163.com>"
Run Code Online (Sandbox Code Playgroud)
还没有找到可以通过message_id搜索的方法。通过这种方式可以获得特定的电子邮件。