How to use CATENATE command in IMAP - imap

Already been through RFC 4469.
Just wanted to know how exactly I can use the CATENATE command.
I also referred the example given in the RFC. But couldn't really execute it against the server.
Any help will be appreciated.

I know this is old issue, but since I was looking this myself, and noticed this I thought I'd share what I found.
So. The simple examples:
s SELECT INBOX
a APPEND INBOX (\Seen) CATENATE (TEXT {53+}
Date: Tue, 03 Jan 2017 22:39:40 +0200
Hello, world.
)
This will work with modern system. You can also use
s SELECT INBOX
a APPEND INBOX (\Seen) CATENATE (TEXT {53}
Date: Tue, 03 Jan 2017 22:39:40 +0200
Hello, world.
)
The thing about catenate is that it can also combine input from other emails. You can do this with URL.
a APPEND INBOX CATENATE (URL "/INBOX;UIDVALIDITY=1483364905/;UID=2/;SECTION=HEADER" TEXT {8}
Hello..
)
a OK [APPENDUID 1483364905 4] Append completed.
FETCH 4:4 (BODY[])
Date: Tue, 03 Jan 2017 22:39:40 +0200
Hello..
)
a OK Fetch completed.
And we have reused headers from mail with UID 2 in INBOX. UIDVALIDITY can be acquired by saying s STATUS INBOX.
The examples in the IETF are bit spooky, but they show how to use mime multipart as input.

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.

How to get subject, content, etc fetched via Net::IMAP

I'm facing trouble decoding messages fetched through ruby's Net::IMAP, here's what I've tried in console
imap = Net::IMAP.new(‘imap.gmail.com’,993,true)
imap.login(“my#gmail.com”, “mypassword”)
imap.select(‘INBOX’)
msgs = []
imap.uid_search(["NOT", "DELETED"]).each do |uid|
msgs << imap.uid_fetch(uid, ['RFC822']).first.attr['RFC822'].to_s
end
Now when I'm doing msgs.first I'm getting this
"Return-Path: <my#gmail.com>\r\n
Received: from 192.168.10.191:3000 ([111.93.167.67])\r\n
by mx.google.com with ESMTPSA id kz4sm35619700pbc.39.1969.12.31.16.00.00\r\n
(version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128);\r\n
Thu, 05 Sep 2013 06:18:24 -0700 (PDT)\r\n
Date: Thu, 05 Sep 2013 18:48:18 +0530\r\n
From: my#gmail.com\r\n
Reply-To: please-change-me-at-config-initializers-devise#example.com\r\n
To: admin#example.com\r\n
Message-ID: <5228849ab79c5_4b57133029c665c4#rajde1.mail>\r\n
Subject: Confirmation instructions\r\n
Mime-Version: 1.0\r\n
Content-Type: text/html;\r\n
charset=UTF-8\r\n
Content-Transfer-Encoding: 7bit\r\n\r\n
<p>Welcome admin#example.com!</p>\r\n\r\n<p>You can confirm your account email through the link below:</p>\r\n\r\n<p>Confirm my account</p>\r\n"
How to decode this, please help. I'm new to this feature.
When you retrieve RFC822 you get the whole thing. If you retrieve BODY.PEEK[HEADER.FIELDS (Subject)] you'll get just the subject. (There's also an ENVELOPE which can be quite handy, it contains Subject, From and a few more, neatly parsed for you.) Fetching the body (I assume that's what you mean by content) is a little more tricky, you need to first retrieve the bodystructure, then retrieve the parts you want, often BODY.PEEK[1] or BODY.PEEK[1.2] or somesuch.
Try using something like this:
body1 = imap.fetch(uid, "RFC822")[0].attr["RFC822"]
mail = Mail.new(body1)
subject = mail.subject
to = mail.to
like that you could take all the value.

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

Why does Chrome use the client cache differently in these two scenarios?

I'm working on a small single-page application using HTML5. One feature is to show PDF documents embedded in the page, which documents can be selected form a list.
NOw I'm trying to make Chrome (at first, and then all the other modern browsers) use the local client cache to fulfill simple GET request for PDF documents without going through the server (other than the first time of course). I cause the PDF file to be requested by setting the "data" property on an <object> element in HTML.
I have found a working example for XMLHttpRequest (not <object>). If you use Chrome's developer tools (Network tab) you can see that the first request goes to the server, and results in a response with these headers:
Cache-Control:public,Public
Content-Encoding:gzip
Content-Length:130
Content-Type:text/plain; charset=utf-8
Date:Tue, 03 Jul 2012 20:34:15 GMT
Expires:Tue, 03 Jul 2012 20:35:15 GMT
Last-Modified:Tue, 03 Jul 2012 20:34:15 GMT
Server:Microsoft-IIS/7.5
Vary:Accept-Encoding
The second request is served from the local cache without any server roundtrip, which is what I want.
Back in my own application, I then used ASP-NET MVC 4 and set
[OutputCache(Duration=60)]
on my controller. The first request to this controller - with URL http://localhost:63035/?doi=10.1155/2007/98732 results in the following headers:
Cache-Control:public, max-age=60, s-maxage=0
Content-Length:238727
Content-Type:application/pdf
Date:Tue, 03 Jul 2012 20:45:08 GMT
Expires:Tue, 03 Jul 2012 20:46:06 GMT
Last-Modified:Tue, 03 Jul 2012 20:45:06 GMT
Server:Microsoft-IIS/8.0
Vary:*
The second request results in another roundtrip to the server, with a much quicker response (suggesting server-side caching?) but returns 200 OK and these headers:
Cache-Control:public, max-age=53, s-maxage=0
Content-Length:238727
Content-Type:application/pdf
Date:Tue, 03 Jul 2012 20:45:13 GMT
Expires:Tue, 03 Jul 2012 20:46:06 GMT
Last-Modified:Tue, 03 Jul 2012 20:45:06 GMT
Server:Microsoft-IIS/8.0
Vary:*
The third request for the same URL results in yet another roundtrip and a 304 response with these headers:
Cache-Control:public, max-age=33, s-maxage=0
Date:Tue, 03 Jul 2012 20:45:33 GMT
Expires:Tue, 03 Jul 2012 20:46:06 GMT
Last-Modified:Tue, 03 Jul 2012 20:45:06 GMT
Server:Microsoft-IIS/8.0
Vary:*
My question is, how should I set the OutputCache attribute in order to get the desired behaviour (i.e. PDF requests fullfilled from the client cache, within X seconds of the initial request)?
Or, am I not doing things right when I cause the PDF to display by setting the "data" property on an <object> element?
Clients are never obligated to cache. Each browser is free to use its own heuristic to decide whether it is worth caching an object. After all, any use of cache "competes" with other uses of the cache.
Caching is not designed to guarantee a quick response; it is designed to, on average, increase the likelihood that frequently used resources that are not changing will already be there. What you are trying to do, is not what caches are designed to help with.
Based on the results you report, the version of Chrome you were using in 2012 decided it was pointless to cache an object that would expire in 60 seconds, and had only been asked for once. So it threw away the first copy, after using it. Then you asked a second time, and it started to give this URL a bit more priority -- it must have remembered recent URLs, and observed that this was a second request -- it kept the copy in cache, but when the third request came, asked server to verify that it was still valid (presumably because the expiration time was only a few seconds away). The server said "304 -- not modified -- use the copy you cached". It did NOT send the pdf again.
IMHO, that was reasonable cache behavior, for an object that will expire soon.
If you want to increase the chance that the PDF will stick around longer, then give a later expiration time, but say that it must check with the server to see if it is still valid.
If using HTTP Cache-Control header, this might be: private, max-age: 3600, must-revalidate. With this, you should see a round-trip to server, which will give 304 response as long as the page is valid. This should be a quick response, since no data is sent back -- the browser's cached version is used.
private is optional -- not related to this caching behavior -- I'm assuming whatever this volatile PDF is, it only makes sense for the given user and/or shouldn't be hanging around for a long time, in some shared location.
If you really need the performance of not talking to the server at all, then consider writing javascript to hide/show the DOM element holding that PDF, rather than dropping it, and needing to ask for it again.
Your javascript code for the page is the only place that "understands" that you really want that PDF to stick around, even if you aren't currently showing it to the user.
Have you tried setting the Location property of the OutputCache to "Client"
[OutputCache(Duration=60, Location = OutputCacheLocation.Client)]
By default the location property is set to "Any" which could mean that the response is cached on the client, on a proxy, or at the server.
more at MSDN OutputCacheLocation

imap command for save a message to draft

i'm building a simple webMail and use imap protocol.
i want to add draft option to my webmail & need an imap command for save a message(which not completed composition) in draft folder?
could anybody help me?
Use the APPEND command. It doesn't matter if the message is incomplete. As long as it's a properly formatted email with a header and a body, you can add it to a folder.
APPEND is in fact the only command that exists in IMAP that allows you to add new content to the remote server, so you would use the same command to save the completed message to a "Sent" folder.
Example:
C: A003 APPEND saved-messages (\Seen) {310}
S: + Ready for literal data
C: Date: Mon, 7 Feb 1994 21:52:25 -0800 (PST)
C: From: Fred Foobar
C: Subject: afternoon meeting
C: To: mooch#owatagu.siam.edu
C: Message-Id:
C: MIME-Version: 1.0
C: Content-Type: TEXT/PLAIN; CHARSET=US-ASCII
C:
C: Hello Joe, do you think we can meet at 3:30 tomorrow?
C:
S: A003 OK APPEND completed

Resources