OfflineIMAP and Mutt with Gmail's All Mail folder - gmail

OfflimeIMAP
I am trying to sync my Gmail - All Mail folder with idlefolders through offlineimap. My .offlineimaprc config has this -
idlefolders = ['INBOX', '[Gmail].All Mail']
My name of my All Mail folder in .mail (where my mailboxes are) looks like
drwx------ 5 ry ry 4096 Oct 12 18:13 [Gmail].All Mail
I think the name is wrong in idlefolders. I see a lot of people online using [Gmail]/All Mail.
My INBOX folder sync fine but All Mail does not.
MUTT
Also trying to set a macro shortcut to All Mail in .muttrc I have -
macro index ga "<change-folder> =[Gmail].All Mail<enter>"
This does not work, but my macro for INBOX does work
macro index gi "<change-folder> =INBOX<enter>"
What's wrong? How should I call my All Mail folder?

for my Mutt 1.5.21, percent encoding works:
macro index ga "<change-folder>=[Gmail]/All%20Mail<enter>"

I think the problem here is the whitespace in the folder. Possible solutions:
Update: As winchendonsprings pointed out, there is a way to escape the whitespace in the folder name. Now we can use a macro to change to All Mail:
bind editor <space> noop
macro index ga "<change-folder>=[Gmail].All Mail<enter>" "Go to all mail"
You use a name transalation to create mailboxes without a
whitespace as described in the
documentation.
For example the translation could look like this:
nametrans = lambda x: re.sub('\[|\]|\s', '_', x)
You should make sure, as the documentation states, that no folder
ends up with the same translated name. You can check this by running
offlineimap with --info.
Another possible solution could be, to register your mailboxes and
simply use a macro to toggle between the index and your list of configured
mailboxes, eg. in your .muttrc:
mailboxes =[Gmail].All\ Mail =[Gmail].Important =[Gmail].Starred
macro index <left> ':mailboxes <enter>c?<toggle-mailboxes>
That provides the benefit that mutt monitors your local mailbox and
tells you if you've got new mail. You can even automate this if you want. Examples can be found here.

Another terrible solution is to just use <complete> to avoid typing a literal space:
macro index ga "<change-folder>=[Gmail]/All<complete><enter>"

Related

Use Japanese characters in subject and attach file with mailx in RedHat Linux

I am trying to use the mailx command for sending email with attachment (zipped) and am facing two issues, below is the command I use:
(echo "$BODY"; UUENCODE $ZIP_FILE $ZIP_FILE) \
| mailx -s $SUBJECT_1 -r " " $SENDER $RECIPIENT
My email subject contains space and Japanese characters.
The variable $SUBJECT_1 has the following statement
Subject: [Budget] Subtype Error and some JAPANESE CHARECTERS
I get bet following error:
contains invalid character '\203'
Moreover for testing purpose I changed the statement of SUBJECT_1 to Test Message
SUBJECT_1="Test Message"
It worked, but I receive only Test instead of Test Message and in the mail I could see two more email ids in the To like Message#domain.com and -r#domain.com
I have not implemented the mail body yet, once subject issue fixed will implement the same in body because Body will also have Japanese characters.
Please help me with this error, how to resolve and what am i doing wrong
There's a list of things you need help with here, more than I want to to handle exhaustively on a sunny Saturday afternoon. But some hints.
Quote your variables.
"$SUBJECT_1" is a single string, whereas $SUBJECT_1 is a list of space-separated words. The second word is your email recipient, and subsequent options are also recipients.
Subject.
The basic idea is that you need to include encoding data in the subject, because email headers are only supposed to include 7-bit ASCII.
Here is a hint at how you put special characters in your Subject line.
Here is another hint.
Here is the RFC that describes in lurid detail what you need to do. Asking your favourite search engine for information about "utf8 email subject" and "rfc1522" is probably a good idea.
Email client.
Finally, rather than learning how to use MIME, consider using mutt instead of mailx to send your mail. Mutt has a -a option to add attachments, making it WAY easier than constructing your own headers and body, which I'm not even sure you'd be able to do with mailx in the first place.

Where are received mails by Mailcatcher stored?

I have installed postfix on my Mac with and changed the following parameters :
mydestination =
relayhost = 127.0.0.1:1025
I've modified mydestination to be blank so that whoever the mail is sent to like bellow in the Terminal it necessarily goes through the relayhost (even if it's sent to #localhost) and I can see it appear in my web-browser in Mailcatcher's tab :
echo "Body test" | mail -s "Subject test" test#dev.local
But here's the thing, when I receive the mail I do receive it instantly with the built-in websockets but if I do reload the page localhost:1080, emails are still there, meaning they must be stored somewhere.
After searching I found that the following URL redirects to a .json that contains received mails that are print out in Mailcatcher's tab :
localhost:1080/messages
But if I do a ls -l in my webroot directory, there's no messages.json that appears. And when you do click on the "Quit" button in Mailcatcher's, then relaunch it by doing mailcatcher and opening again localhost:1080 mails have disappeared...
I don't understand, is there a file that is deleted when you do click "Quit" and that I might haven't seen ?
Thanks for your help !
If you check the source on GitHub you will find something like this SQLite3::Database.new(":memory:", :type_translation => true).tap do |db| in mail.rb.
You may not have noticed, but MailCatcher uses SQLite, and the above tells you that it is configured to run in memory. So, when turning off MailCatcher all the rows that are contained in this database are lost.

How to whitelist recipients before mail goes to spamassassin?

I've been looking everywhere for a solution but didn't find.
What I need is to whitelist some recipient addresses so they won't ever go to the spamassassin filtering.
In my master.cf in postfix I have this:
spamassassin unix - n n - - pipe
user=spamd argv=/usr/bin/spamc -f -e
/usr/sbin/sendmail -oi -f ${sender} ${recipient}
Thanks in advance.
From https://spamassassin.apache.org/full/3.4.x/doc/Mail_SpamAssassin_Conf.html
whitelist_to user#example.com
If the given address appears as a recipient in the message headers (Resent-To, To, Cc, obvious envelope recipient, etc.) the mail will be whitelisted. Useful if you're deploying SpamAssassin system-wide, and don't want some users to have their mail filtered. Same format as whitelist_from.
There are three levels of To-whitelisting, whitelist_to, more_spam_to and all_spam_to. Users in the first level may still get some spammish mails blocked, but users in all_spam_to should never get mail blocked.
The headers checked for whitelist addresses are as follows: if Resent-To or Resent-Cc are set, use those; otherwise check all addresses taken from the following set of headers:
To
Cc
Apparently-To
Delivered-To
Envelope-Recipients
Apparently-Resent-To
X-Envelope-To
Envelope-To
X-Delivered-To
X-Original-To
X-Rcpt-To
X-Real-To
Open this file:
/etc/spamassassin/local.cf and add this line:
whitelist_from abc#def.com
That will whitelist the address. To blacklist an address just use
blacklist_from abc#def.com
Also, I'm running Ubuntu, and they also include a file in the same location,
65_debian.cf. You can add that there as well.
Make sure this plugin is uncommented:
ifplugin Mail::SpamAssassin::Plugin::Shortcircuit
whitelist_from abc#def.com
...
endif
All your whitelist/blacklist rules along with custom scores and rules should fall within these lines.

postfix problems with pattern in virtual file

We are trying to forward all emails to a specific email address. I think everything is set up okay, such as 'main.cf' and 'virtual-regexp' files. If we put the following in the 'virtual' file, the forwarding works correctly:
#ourmail.com mainid#ourmail.com
However, if we try to use the following in 'virtual' to send ALL email to the ID, it ignores it and sends it to the original user:
(.*) mainid#ourmail.com
We got the idea for the above from the following question and answer:
postfix 2.9.6.1 forward all mail to an external mail address
Any ideas why the pattern '(.*)' doesn't work? We've tried so many different patterns that our heads are starting to spin.
we solved the issue.
You need to complete the steps listed in the link above. But, in addition, you need to comment out the following lines in main.cf (if they are there) before restarting the postfix process:
virtual_alias_maps = hash:/etc/postfix/virtual
virtual_alias_domains = hash:/etc/postfix/virtual

Perl: Read email and use message content as stdin for an excel update

I am looking for some help with starting a Perl script. I'm relatively inexperienced with Perl so help would be appreciated :)
Basically, want to start a project to write a script that helps keep up to date with hours I have been working. Basically I would like the script to E-mail (automated using cron) me reminding me to send my hours each day, then I send an e-mail back with the message as something like
"03/02/14 7.30 18.30"
The script will then read the data and update an excel spreadsheet keeping a log of hours.
I know how to do everything except having the script read an e-mail. I have been doing research into MIME::* MAIL::* but I'm not entirely sure which package would be the best and how to actually go about it.
As #mpapec suggested you could read email using IMAP or a local mailbox on a linux box.
In windows you could use OLE and read emails in an outlook: Perl: Win32::OLE and Microsoft Outlook - Iterating through email attachments efficiently
You could read emails on exchange in this way: http://metacpan.org/pod/Email::Folder::Exchange
If I were you I would use IMAP to access emails. It is platform independent and not too hard to use (I used it in the past and it was reliable).
http://metacpan.org/pod/Net::IMAP::Client
my $imap = Net::IMAP::Client->new(
server => 'mail.you.com',
user => 'USERID',
pass => 'PASSWORD');
# select folder
$imap->select('INBOX');
#newest first
my $messages = $imap->search({
FROM => 'you',
SUBJECT => 'your email subjet',
}, [ '^DATE' ]);
# fetch full message (newest)
my $data = $imap->get_rfc822_body($messages->[0]);
#process
store_data_in_excel($data);
#move to archive
$imap->copy([$messages->[0]], 'Archive');
$imap->add_flags(\#msg_ids, '\\Deleted');
$imap->expunge;

Resources