Using Google Mail Actions - ruby-on-rails

So I've been reading about the little action icons in Google Mail and I'm trying to set this up inside Rails 3. I have the template, I have the message itself, I have SMTP set up to Google Mail as well.
According to this article:
http://googleappsdeveloper.blogspot.com/2013/05/introducing-actions-in-inbox-powered-by.html
(read the comments) the only way to test this out is to send the messages from you to you (the sender and recipient have to be the same). Unfortunately, it looks like you still have to DKIM or SPF validate the message as well.
So here's the question: Has anybody been able to test this inside a dev environment? When I use GMail SMTP, I don't get a DKIM signature so it won't show the action icon on the far right.
Message Body:
Received: -
Date: Sat, 22 Feb 2014 15:25:45 -0800
From: me
To: me
Message-ID: <530931f945de6_17c563fc73085e6e86978c#BigMac.local.mail>
Subject: Testing Gmail action Schemas :
Mime-Version: 1.0
Content-Type: multipart/alternative;
boundary="--==_mimepart_530931f943db6_17c563fc73085e6e869643";
charset=UTF-8
Content-Transfer-Encoding: 7bit
----==_mimepart_530931f943db6_17c563fc73085e6e869643
Content-Type: text/plain;
charset=UTF-8
Content-Transfer-Encoding: 7bit
EMAIL CONTENT GOES HERE
----==_mimepart_530931f943db6_17c563fc73085e6e869643
Content-Type: text/html;
charset=UTF-8
Content-Transfer-Encoding: 7bit
<html>
<header>
<div itemscope itemtype="http://schema.org/EmailMessage">
<meta itemprop="description" content="Click here to view your ticket."/>
<div itemprop="action" itemscope itemtype="http://schema.org/ViewAction">
<link itemprop="url" href="https://support.und0.com/tickets/1"/>
<meta itemprop="name" content="View ticket"/>
</div>
</div>
</header>
<body>
<div>EMAIL CONTENT GOES HERE</div>
</body>
</html>
----==_mimepart_530931f943db6_17c563fc73085e6e869643--

Related

Sendgrid GEM bug while sending plain/text e-mail

Im tring to send an e-mail via the sendgrid gem for ruby on rails.
This is my code for the mailer:
def send_form(params)
#params=params
mail( :to => 'my_email',
:subject => 'my_subject',:content_type => "text/plain")
end
It is loading my view which is send_form.json.erb and in the view there is this:
<%= raw #params.to_json %>
Now, the problem here is that the source code from the e-mail has 2 emails(?), one with plain text and one with HTML.
This is a multi-part message in MIME format...
------------=_1448758618-20748-809
Content-Type: text/plain;
charset=UTF-8
Content-Transfer-Encoding: 7bit
{"versao":"cee'd SW - 1.6 CRDi ISG EX","concessionario":"Sotabi","extraEmail":"gerencia#sotabi.p","nome":"Miguel Rebola","email":"miguelrebola21#gmail.com","telefone":"968823502","comentarios":"fdfd","autorizo":"yes"}
------------=_1448758618-20748-809
Content-Type: text/html; charset="UTF-8"
Content-Disposition: inline
Content-Transfer-Encoding: 7bit
<html><body>
<p>{"versao":"cee'd SW – 1.6 CRDi ISG EX","concessionario":"Sotabi","extraEmail":"gerencia#sotabi.p","nome":"Miguel Rebola","email":"miguelrebola21#gmail.com","telefone":"968823502","comentarios":"fdfd","autorizo":"yes"}</p>
<img src="https://u1373375.ct.sendgrid.net/wf/open?upn=u0x3fSBqEx-2Fl-2BmgujqmE8BQomXBLbogF-2Bc6F-2BtlRZ6DF0HBXi526k5pl8ZUC-2FxtIp9ic36mMF2aQ4d6eJ5Lqq9panqdI3Ye7hmz4ajbhDO44ePVyM2SMDDBBWWMpJ5l50gYvbwVmo7S80MmO-2BlSAaFwiQpqgTXdMFRmz0vHxy-2BdXYgxbqCs5K3msoeQ4SQS-2BZqoqDpo2wVLTeQrEbKzxE2cQn1u-2FORF6fYLTNqw560g-3D" alt="" width="1" height="1" border="0" style="height:1px !important;width:1px !important;border-width:0 !important;margin-top:0 !important;margin-bottom:0 !important;margin-right:0 !important;margin-left:0 !important;padding-top:0 !important;padding-bottom:0 !important;padding-right:0 !important;padding-left:0 !important;"/>
</body></html>
I need to send only the plain/text. Any idea??
Needed to change the confgiuration on Sendrigd website.
Go to Settings https://app.sendgrid.com/settings/mail_settings
find Plain Content parameter and switch it on.

Sendgrid template

I am trying to send emails through using sendgrid template. But still sent, standard template.
def send_test_email(user)
#user = user
sendgrid_unique_args "filters" => {
templates" => {
"settings" => {
"enable" => 1,
"template_id" => "5e4a1ef6-a948-455f-b194-cec87ef88b0e"
}
}
}
mail( :to => #user.email,
:subject => 'Thanks for signing up for our amazing app' )
end
After sending
Sent mail to test#ya.net (699.1ms)
Date: Thu, 13 Aug 2015 10:00:04 +0300
From: example#example.com
To: test#ya.net
Message-ID: <55cc407412764_23922fba2642131f#Vlad.mail>
Subject: Thanks for signing up for our amazing app
Mime-Version: 1.0
Content-Type: text/html;
charset=UTF-8
Content-Transfer-Encoding: 7bit
X-SMTPAPI: {"unique_args": {"filters": {"templates": {"settings":
{"enable":1,"template_id": "5e4a1ef6-a948-455f-b194-cec87ef88b0e"}}}}}
<html>
<head>
<meta content='text/html; charset=UTF-8' http-equiv='Content-Type' />
</head>
<body>
<h1>Thanks for signing up, Jovani!</h1>
<p>Thanks for joining and have a great day! Now sign in and do
awesome things!</p>
</body>
</html>
How do I make that poisoned sendgrid template?
Your question does not clearly state the problem, but one thing I did notice is that your HTML does not have <%body%> which send grid needs in order to work with templates properly.

Test google schema in my gmail account

I'm a starter in Google Schema, I've followed the getting started, but it doesn't work... I've changed to another more simple json-ld, simple actions, but ....
I'm testing with a Django project, in my local, django smtp config to smpt.gmail.com. Same from and to email. I can see the email, but I can't see go-to-action....
This is my original mail:
Return-Path: <XX#gmail.com>
Received: from tomas-H55M-D2H (37.130.151.22.radiocable.net. [37.130.151.22])
by mx.google.com with ESMTPSA id n3sm2456222wix.1.2015.05.12.04.20.07
for <XX#gmail.com>
(version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
Tue, 12 May 2015 04:20:07 -0700 (PDT)
MIME-Version: 1.0
Content-Type: text/html; charset="utf-8"
Content-Transfer-Encoding: 7bit
Subject: Testing
From: XX#gmail.com
To: XX#gmail.com
Date: Tue, 12 May 2015 11:20:07 -0000
Message-ID: <20150512112007.23123.78164#tomas-H55M-D2H>
Reply-To: XX#gmail.com
<html>
<head>
<script type="application/ld+json">
{
"#context": "http://schema.org",
"#type": "EmailMessage",
"description": "Check this out",
"action": {
"#type": "ViewAction",
"url": "https://www.youtube.com/watch?v=eH8KwfdkSqU"
}
}
</script>
</head>
<body>
<p>
This a test for a Go-To action in Gmail.
</p>
</body>
</html>

ActionMailer responds with "501 5.5.4 Invalid argument"

I'm working on an application with Rails 4 on Ruby 2.0.0. The application sends out an email after a registration in Devise.
This is the code that sends the email:
app/models/sponsor.rb:
after_create :send_email_to_admin
private
def send_email_to_admin
AdminMailer.new_sponsor_email(self).deliver
end
app/mailers/admin_mailer.rb
class AdminMailer < ActionMailer::Base
default to: '**removed**'
def new_sponsor_email(sponsor)
#sponsor = sponsor
p #sponsor
mail(subject: "New Sponsor Registration")
end
end
And this is the generated email from the log file:
Sent mail to **removed** (725.5ms)
Date: Mon, 02 Sep 2013 15:01:03 -0400
From: **removed**
To: **removed**
Message-ID: <5224e06f4dddd_2e5a3fa0452dcfd874597#centaur.mail>
Subject: New Sponsor Registration
Mime-Version: 1.0
Content-Type: multipart/alternative;
boundary="--==_mimepart_5224e06f4cca1_2e5a3fa0452dcfd87441a";
charset=UTF-8
Content-Transfer-Encoding: 7bit
----==_mimepart_5224e06f4cca1_2e5a3fa0452dcfd87441a
Content-Type: text/plain;
charset=UTF-8
Content-Transfer-Encoding: 7bit
A new sponsor has signed up!
==========================
----==_mimepart_5224e06f4cca1_2e5a3fa0452dcfd87441a
Content-Type: text/html;
charset=UTF-8
Content-Transfer-Encoding: 7bit
<!DOCTYPE html>
<html lang='en'>
<head>
<meta content='text/html; charset=UTF-8' http-equiv='Content-Type'>
</head>
<body>
<h1>A new sponsor has signed up!</h1>
</body>
</html>
----==_mimepart_5224e06f4cca1_2e5a3fa0452dcfd87441a--
when I try to test the code by creating a sponsor, I just get this error:
Net::SMTPSyntaxError in Devise::RegistrationsController#create
501 5.5.4 Invalid argument
My understanding is that this is typically because the email is and invalid email, but all of my emails are very simple, in the format of name#domain.tld and no-reply#domain.tld.
The issue seemed to be that I was using "domain" in my smtp_settings. When I removed that, I was able to send emails from both Mailgun and Gmail

Rails mailer and links not working under Thunderbird

I want to send html email's with my Rails Mailer.
Could be multipart/alternative or only text/html.
Problem is, when I send an email with a link, it appears well on Gmail, but not so good in Thunderbird.
The problem is, that in Thunderbird, the link is 'not clickable' - it's highlighted like a link, but clicking on it does nothing.
Links on other mails (not sent from Rails Mailer) work flawlessly.
So my question is: how to properly send an html email, so it will be viewed properly?
Mailer code:
class MyMailer < ActionMailer::Base
def mailing_delivery(email, subject)
mail(:to => email, :subject => subject)
end
Mail view:
# mailing_delivery.html.haml
%p
Thanks! Its your mailer!
%p
= link_to "Google", "google.com"
Source of email (some parts cut-out):
Date: Thu, 18 Aug 2011 14:32:34 +0200
From: xxx
To: xxx
Message-ID: <4e4d0662bf96e_41024be957a57974#xxx.mail>
Subject: Super news!
Mime-Version: 1.0
Content-Type: text/html;
charset=UTF-8
Content-Transfer-Encoding: 7bit
X-O2-Trust: 2, 64
X-O2-SPF: neutral
<p>
Thanks! It's your mailer!
</p>
<p>
Google
</p>
Of course Rails 3. Thunderbird 5.0, but that's not the issue - because somehow other mails show up good.. And I don't think it's app specific.
What should I do, to make this work?
Edit: I tried to change the 'content-transfer-encoding' header with no success, by doing mail(:to => email, :subject => subject, "Content-Transfer-Encoding" => value) or in class default "Content-Transfer-Encoding" => value with no luck.. how to change that?
Emails that works good under Thunderbird have Content-Transfer-Encoding: quoted-printable (or eventually base64) so maybe that's the issue? How do I change it?
Edit 2: I managed to change the Content-Transfer-Encoding to quoted-printable but it's cutting the content, like this:
Date: Thu, 18 Aug 2011 22:04:21 +0200
From: xxx
To: xxx
Message-ID: <4e4d704557839_151c4e4957c2132e#xxx.mail>
Subject: Super news!
Mime-Version: 1.0
Content-Type: text/html;
charset=UTF-8
Content-Transfer-Encoding: quoted-printable
X-O2-Trust: 2, 63
X-O2-SPF: neutral
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://ww=
w.w3.org/TR/html4/loose.dtd">
<html>
<body>
<p>
Thanks! It's your mailer!
</p>
<p>
<a href=
One other thing: why is there a newline in Content-Type ? I didn't see it in other (working good) mails. How I can get rid of it?
Maybe it'll work if you fix your html. So instead of just having:
<p>
Thanks! It's your mailer!
</p>
<p>
Google
</p>
try:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<body>
<p>
Thanks! It's your mailer!
</p>
<p>
Google
</p>
</body>
</html>

Resources