what does the ActionMailer deliver command return? - ruby-on-rails

I'm trying to figure out how to gracefully inform a user that an e-mail has not been sent from Rails.
The issue is this line of code:
OrderNotifier.received(#order).deliver
and what happens when the smtp server does not respond to the deliver command (smtp server is down, for instance). I've seen example code like:
#response_from_deliver = OrderNotifier.received(#order).deliver
but can find no documentation that says either this is a valid assignment or, if it is, what the various responses from an ActionMailer deliver might be.
Thanks for any information.

You will get back the Mail::Message object type. Apidock.com looks like it has some good information on ActionMailer.
#<Mail::Message:70225058423980,
Multipart: false, Headers: <Date: Mon, 20 Jan 2014 12:06:05 -0600>,
<From: info#socialrest.me>,
<To: myemail#gmail.com>,
<Message-ID: <52dd658d8f0f7_11643fde8d219160235e4#iMac.local.mail>>,
<Subject: Welcome to My Site>,
<Mime-Version: 1.0>,
<Content-Type: text/html>,
<Content-Transfer-Encoding: quoted-printable>>

Related

How do I manage to get the "Unsubscribe" link right next to the From address on Gmail?

I'm working on an email marketing project, and I'm trying to get that link shown on the emails sent from our servers.
I'm including the "List-Unsubscribe: , " header, besides other headers considered good practices by RFC, support.google, ...
Is it possible that we are doing something wrong on the headers construction?
This is the link I'm talking about:
Unsubscribe link
Our headers:
Received: by 10.37.51.2 with SMTP id z2csp2282796ybz;
Tue, 4 Oct 2016 09:32:50 -0700 (PDT)
X-Received: by 10.159.48.147 with SMTP id j19mr2901380uab.45.1475598769950;
Tue, 04 Oct 2016 09:32:49 -0700 (PDT)
Return-Path: <*****************#74344.returnpath.dattanet.com>
Received: from mta107.185.esmkt.net (mta107.185.esmkt.net. [200.58.107.185])
by mx.google.com with ESMTPS id 7si1993119vkg.227.2016.10.04.09.32.48
for <*****************#gmail.com>
(version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
Tue, 04 Oct 2016 09:32:49 -0700 (PDT)
Received-SPF: pass (google.com: domain of bounces-*************=gmail.com#74344.returnpath.dattanet.com designates 200.58.107.185 as permitted sender) client-ip=200.58.107.185;
Authentication-Results: mx.google.com;
dkim=pass header.i=#74344.senders.dattanet.com;
dkim=pass header.i=#gmail.esmkt.net;
spf=pass (google.com: domain of bounces-*************=gmail.com#74344.returnpath.dattanet.com designates 200.58.107.185 as permitted sender) smtp.mailfrom=bounces-***************=gmail.com#74344.returnpath.dattanet.com
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; s=esdkim; d=74344.senders.dattanet.com; h=From:Reply-To:List-ID:Sender:List-Unsubscribe:Subject:Content-Type:MIME-Version:To:Date:Message-ID; i=*************#74344.senders.dattanet.com; bh=8JDi/gUM6J+D33yKj8l/4tZW5kFud7LHPmwWlCcrfqU=; b=WPSqCxYnM9WW8keFP8N3R4QZ8LkGIkoT4tftaVM02NsTdY4krn51J4CFG0FvZ8bQhebdqwpg4mTw
SB14IkPGNVNHMgK2+u2q25f4Qa7psu/cc/lPL93ss++9H99JtdSakeimOhbHGy4O2zm9TVgQYiXu
eq/kTZs5pZUuW0/PPek=
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; s=dkim; d=gmail.esmkt.net; h=From:Reply-To:List-ID:Sender:List-Unsubscribe:Subject:Content-Type:MIME-Version:To:Date:Message-ID; bh=8JDi/gUM6J+D33yKj8l/4tZW5kFud7LHPmwWlCcrfqU=; b=hwo3JCkn4tLxNPZyDkpCc85ND9PMQxlIXKoQqmCERhBwmm70+/Ga53HLlpr82ENHeQ9wklyy26/G
jqAB9wla/JZhaBdL/QiibJZi4VuxuGHsOC3s4FuyU68VWnQLPKySvtMRVPkuD50M0Rz6uFCzWRYz
qkXj08TTGbSWEmu76sA=
Precedence: bulk
X-DM-SENDER: MAILTX
From: *********#********.com
Reply-To: **********#***********.com
X-DM-Tracking-Domain: 1
X-Mailer-CSID: 1BRsE7-1426929
X-DM-Priority: 10
X-Report-Abuse: Please report abuse for this campaign here:
http://envialosimple.com/abuse/
List-ID: <74344:2>
Sender: *******=******.com#74344.senders.dattanet.com
Return-Path: bounces#74344.returnpath.dattanet.com
List-Unsubscribe: <mailto:unsubscribe#74344.track.dattanet.com?body=#s-1key#223bdbd85ee9bc39069593195d9b8adadf8c694a340e311511028f29c29314b078d864a0660e40e88845201193021993d6b3fdec739d1c851b7960b2adb635a27c#e-1key#>, <http://74344.track.dattanet.com/track/click?u=unsubscribe&p=37343334343a3139373a3137383a303a303a30&m=2&s=043258db01b40ed12a95ef7f5f49a2b9>
Subject: **************
Content-Type: multipart/alternative; boundary="=_e61683699dd8c4bbfbaf3f6d4aa2e716"
MIME-Version: 1.0
To: <**************#gmail.com>
Date: Tue, 4 Oct 2016 13:32:47 -0300
Message-ID: <0.0.5.A9F.1D21E5CF13826CA.129B3#mta107.185.esmkt.net>
Thanks in advance!
Even i was trying something like that and found that it is google's which scrapes the data from the Email Body and puts and Unsubscribe link right next to the name.
List-Unsubscribe will and can only ensure that the UNSUBSCRIBE Link is present when you press the downward arrow next to me .
The unsubscribe option is only shown for senders with a high reputation.
See Gmail unsubscribe link does not appear
As far as I know there is already an existing Gmail feature wherein you may opt to add "Unsubscribe" button.
From this Gmail forum, suggested steps are as follows:
Log-in to your Google group.
Click on the Gear icon top right of the home page, from the drop-down select "Group settings".
Click to expand "Settings" in the left panel, and click on "Email Options".
In the right panel, under Email Footer you should be able to spot "Display how to unsubscribe from this group by email".
Check the box to the left of it.
You will be prompted to save your changes on Exit.
Another option is to use this add-on. As noted in the given link, with this add-on, it is your responsibility to add an unsubscribe link to your emails if you think it is needed.
For now on, there is no built-in unsubscribe feature in the add-on. We recommend using Google Form to let people tell you they don't want to receive your emails anymore. People will fill the form, submit their email address and you will be able to remove those email addresses from your mailing list to stop sending them emails.
Steps on how to implement this can be found in this given documentation or you may also check this article for the newer version.

Sending EWS invites with Viewpoint via heroku dyno get blocked by spam filter

I'm using the excellent Viewpoint ruby gem to create an event in my EWS calendar and send invites to attendees, on an heroku app.
This works very well in development, and in heroku production console.
When I do it from an heroku web dyno, the event gets created with correct attendees, but invites are not sent. Instead, I receive an email from exchange server saying my outbound message can't be delivered due to spam detection:
Remote Server returned '550 5.1.8 Access denied, spam abuse detected'
En-tĂȘtes de message d'origine :
Authentication-Results: gmail.com; dkim=none (message not signed)
header.d=none;
Received: from AMSPR01MB103.eurprd01.prod.exchangelabs.com (10.242.91.146) by
AMSPR01MB101.eurprd01.prod.exchangelabs.com (10.242.91.140) with Microsoft
SMTP Server (TLS) id 15.1.154.19; Mon, 4 May 2015 09:18:41 +0000
Received: from AMSPR01MB103.eurprd01.prod.exchangelabs.com ([169.254.4.13]) by
AMSPR01MB103.eurprd01.prod.exchangelabs.com ([169.254.4.13]) with mapi id
15.01.0154.018; Mon, 4 May 2015 09:18:40 +0000
Content-Type: application/ms-tnef; name="winmail.dat"
Content-Transfer-Encoding: binary
From: Nicolas Marlier <nicolas#marlier.onmicrosoft.com>
To: "nmarlier#gmail.com" <nmarlier#gmail.com>
Subject: =?utf-8?B?Tm91dmVsIMOpdsOobmVtZW50?=
Thread-Topic: =?utf-8?B?Tm91dmVsIMOpdsOobmVtZW50?=
Thread-Index: AdCGSDTEah5PWrxeqEy/iSmi4R7oNg==
X-MS-Exchange-MessageSentRepresentingType: 1
X-MS-Exchange-Calendar-Originator-Id: 52a7b57c-9423-417c-8560-37fa3ae0e74a;/o=ExchangeLabs/ou=Exchange
Administrative Group
(FYDIBOHF23SPDLT)/cn=Recipients/cn=096fdd7902e244399c6fbd8bf2401533-nicolas
Date: Mon, 4 May 2015 09:18:40 +0000
Message-ID: <AMSPR01MB10304E80D885534965D74C3F7D20#AMSPR01MB103.eurprd01.prod.exchangelabs.com>
Accept-Language: fr-FR, en-US
Content-Language: en-US
X-MS-Has-Attach:
X-MS-TNEF-Correlator: <AMSPR01MB10304E80D885534965D74C3F7D20#AMSPR01MB103.eurprd01.prod.exchangelabs.com>
MIME-Version: 1.0
X-Originating-IP: [54.163.190.73]
Return-Path: nicolas#marlier.onmicrosoft.com
X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:AMSPR01MB101;
X-Microsoft-Antispam-PRVS:
<AMSPR01MB10156182A79CE60E68A4106F7D20#AMSPR01MB101.eurprd01.prod.exchangelabs.com>
X-Exchange-Antispam-Report-Test: UriScan:;
X-Exchange-Antispam-Report-CFA-Test:
BCL:0;PCL:0;RULEID:(601004)(5005006)(3002001);SRVR:AMSPR01MB101;
X-Forefront-PRVS: 05669A7924
I'm thinking this may be caused by the heroku instance not being whitelisted, and I'm considering trying something like the Proximo add-on to fix that. Any thought on another way to make sure the invite is being sent ?

Why are my automated confirmation / subscription emails getting flagged as spam in gmail?

So I have a rails app set up with devise that sends out account confirmation and password reset emails. The emails get sent out using the sendmail command using postfix for smtp. I have DKIM set up and gmail is accepting the signatures as valid. I also have SPF set up correctly.
Gmail is giving me this message as an "explanation" of why my emails are getting spammed:
Why is this message in Spam? It contains content that's typically used
in spam messages.
As descriptive as that is, I have no idea what content in particular is typically used in spam messages. I've tried tweaking the text, changing to html, then to text+html, changing the from address, adding the user's full name to the to address in addition to the email. I'm stumped. Maybe another pair of eyeballs can point out something stupid that I've simply overlooked.
The full text of the message follows with personally identifiable information redacted.
Delivered-To: myaddress#gmail.com
Received: by 10.216.199.130 with SMTP id x2csp42610wen;
Sun, 16 Jun 2013 13:16:13 -0700 (PDT)
X-Received: by 10.224.174.6 with SMTP id r6mr13525400qaz.87.1371413772413;
Sun, 16 Jun 2013 13:16:12 -0700 (PDT)
Return-Path: <account-services#booyango.com>
Received: from booyango.com (node1.booyango.com. [97.107.138.232])
by mx.google.com with ESMTP id k6si3223197qcj.4.2013.06.16.13.16.11
for <myaddress#gmail.com>;
Sun, 16 Jun 2013 13:16:12 -0700 (PDT)
Received-SPF: pass (google.com: domain of account-services#booyango.com designates 97.107.138.232 as permitted sender) client-ip=97.107.138.232;
Authentication-Results: mx.google.com;
spf=pass (google.com: domain of account-services#booyango.com designates 97.107.138.232 as permitted sender) smtp.mail=account-services#booyango.com;
dkim=pass header.i=#booyango.com
Received: by booyango.com (Postfix, from userid 33)
id 7CEC133DF5; Sun, 16 Jun 2013 20:16:11 +0000 (UTC)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=booyango.com;
s=default; t=1371413771;
bh=iXfBZB6q0fPI+Yms0E8FC1P/T9J+3enBFtTrsjcTADY=;
h=Date:From:Reply-To:To:Subject;
b=AGw4SXj6UN0lpEo0FSO91s3aAYDsmAHZVqBvvYGQPW6Jp1UhfAQFlIE1AYY0CcoUq
Xb3Mn4vul1WXpdWIZMPEgHXJ3SwvEvSxDfDEeYTNiGRoI+DW7vFopTo+1rQeLLdS/B
j6iIKFsJUAOz0n1yh9/gasXJeOv4fmK6+ZoMhLfQ=
Date: Sun, 16 Jun 2013 20:16:11 +0000
From: Booyango Account Services <account-services#booyango.com>
Reply-To: Booyango Account Services <account-services#booyango.com>
To: me <myaddress#gmail.com>
Message-ID: <51be1d0b55c16_44f38e887057054#node1.booyango.com.mail>
Subject: [Booyango] Reset password instructions
Mime-Version: 1.0
Content-Type: text/plain;
charset=UTF-8
Content-Transfer-Encoding: 7bit
Oops, it looks like you lost your Booyango password.
You can use the following link within the next 24 hours to reset your password:
http://booyango.com/users/password/edit?reset_password_token=<reset_token>
Thanks,
The Booyango Team
I have had problems with this in the past, and found solutions to be largely hit and miss. If the server which is sending your mail happens to be on a black list because of previous spammers linked to your server/IP address, you are probably out of luck. Otherwise, I have had limited success by playing with different header variables; also plain text emails tend to have higher delivery success rates than HTML - in my experience (although, I realise you are already doing this).
Also try rephrasing your subject line or body text, you may just be getting caught by a spam rule looking out for a pattern you have accidently stumbled upon.
I found the my devise or rails emails were sent to gmail span if
1) they included a link (ex. confirmation token)
2) the subject was blank

Rails 3.2 ActionMailer not rendering html in production

I have a production machine that is your basic CentOS machine on Amazon AWS, nothing special there.
I am essentially running this:
#digest = WeeklyDigest.most_recent.first
#mailer = DigestMailer.weekly_digest(#digest)
#mailchimp = MailChimp.new
#mailchimp.new_digest(#mailer.body.to_s)
What this code does is finds my latest weekly_digest, generate a new mailer using that, and then I grab the html from that and send it to mailchimp.
I have a weekly_digest.html.slim in app/views/digest_mailer and I have a digest_mailer.html.slim in app/views/layouts.
All of this works fine on development. #mailer returns this:
#<Mail::Message:70180219750380, Multipart: false, Headers: <From: no-reply#example.com>, <To: fake#fake.com>, <Subject: Weekly Digest>, <Mime-Version: 1.0>, <Content-Type: text/html>>
When I run the exact same code on my AWS machine it returns:
#<Mail::Message:158221880, Multipart: false, Headers: <From: no-reply#example.com>, <To: fake#fake.com>, <Subject: Weekly Digest>, <Mime-Version: 1.0>, <Content-Type: text/plain>>
The content type on dev is html and its text/plain on prod.
Any ideas about why this might happen? Something in the environment settings? I'm not finding much helpful in the docs.
Could be a discrepancy in default_content_type between your environment configurations. Try adding:
config.action_mailer.default_content_type = 'text/html'
To either your production.rb config file, or optionally your application.rb config file.
You should also check if a text template exists at app/views/digest_mailer/weekly_digest.text.erb and remove it since you're only trying to send HTML emails anyway.
Longterm you should consider sending multipart emails with both text and HTML. The Premailer Gem makes it really easy by automatically generating the text-part from the HTML template. That way you don't have to maintain both a text and HTML template and keep them in sync.

ActionMailer - limit on number of recipients?

I've got Capistrano set up to send emails after deploying my RoR (2.3.8) application. I have a config/cap_mailer.rb file that basically looks like:
ActionMailer::Base.smtp_settings = {
:address => my,
:port => exchange,
:domain => server,
:authentication => settings,
:user_name => are,
:password => here
}
class CapMailer < ActionMailer::Base
def deploy_notification(cap_vars)
recipients cap_vars[:notify_emails]
from 'deploy#my.org'
subject "New app!"
body "Deployed application...blah blah blah"
end
end
Then, in my deploy.rb file, I have the following:
require 'config/cap_mailer.rb'
...
desc "Email recipients of deployment"
task :notify do
puts " * Sending notification email"
set :notify_emails, ["test1#my.org", "test2#my.org", etc.]
CapMailer.deliver_deploy_notification(self)
end
Now this all works fine and dandy......until I put more than 7 email addresses in the :notify_emails array. Up to 7 works fine, but when I put 8 or more (all valid addresses), the email gets screwed up a little bit (still goes through to the first 7, at least). Looking at the email header, it shows that it is cutting off the 8th (and 9th, 10th, ...) address from the 'To:' and putting it in the message body.
HEADER:
thread-index: AcyaZxlga08L9p35QYKJ22aiGG2zeA==
Content-Class: urn:content-classes:message
Importance: normal
Priority: normal
X-MimeOLE: Produced By ...
Received: from exchange.my.org ([ip address]) by ...; Thu, 3 Nov 2011 14:28:08 -0600
Date: Thu, 3 Nov 2011 14:28:08 -0600
From: deploy#my.org
To: test1#my.org,
test2#my.org,
test3#my.org,
test4#my.org,
test5#my.org,
test6#my.org,
test7#my.org
HEADER:
BODY:
test8#my.org
Message-Id:
<4eb2f95816341_135ff800c21ac130#my_box.local.tmail>
Subject: New app!
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Return-Path: deploy#my.org
X-OriginalArrivalTime: 03 Nov 2011 20:28:08.0494 (UTC)
FILETIME=[19601CE0:01CC9A67]
Deployed application...blah blah blah
BODY:
In addition, the subject does not appear on the email, even though the "error text" in the message body shows the correct subject.
Does anyone have any idea why this is happening? What is it about having 8 or more recipients that breaks it? I've Googled around and can't find anything about ActionMailer having a limit on the number of recipients (even if there were, that's a small limit). Is there something I'm missing? Any help is appreciated! I really need to be able to send to 8 or more recipients.
UPDATE: Setting the recipients directly with an array of 8 or more addresses still breaks things, so this clearly seems like a problem with ActionMailer and not Capistrano.
recipients ["test1#my.org", "test2#my.org", "test3#my.org", "test4#my.org",
"test5#my.org", "test6#my.org", "test7#my.org", "test8#my.org", "test9#my.org"]
The 7th email address is not followed by a comma, which could be the problem. Try passing a string to recipients, like cap_vars[:notify_emails].join(','), with no newlines.
Try passing a string to recipients without commas (there have been reports of commas as a problem), like:
cap_vars[:notify_emails].join(' ')
With all respect some simple things that you might overlook in debugging difficult errors:
If its mail server related install it on another production server? If you not sure it is the mail server acting up looking for another error may be of no help.
Try upgrade rails / ruby ? Perhaps its a bug in the code

Resources