Gmail IMAP search by multiple senders - imap

This search query seems valid to me :
UID SEARCH OR ( OR ( OR (FROM "def#gmail.com") (FROM "abc#gmail.com")) (FROM "ghi#gmail.com")) (FROM "jkl#gmail.com")
but I got "Could not parse command" error when trying to query that command to Gmail IMAP.
I tried
UID SEARCH OR OR OR FROM "def#gmail.com" FROM "abc#gmail.com" FROM
"ghi#gmail.com" FROM "jkl#gmail.com"
and
UID SEARCH OR (FROM "jkl#gmail.com") ( OR (FROM "ghi#gmail.com") ( OR
(FROM "abc#gmail.com") (FROM "def#gmail.com")))
and
UID SEARCH OR OR OR FROM def#gmail.com FROM abc#gmail.com FROM
ghi#gmail.com FROM jkl#gmail.com
all failed with "Could not parse command".

First, make sure you have a mailbox selected or else it will not work. Secondly, make sure you are prefixing your commands with a tag or else IMAP will interpret your UID command as a tag and will actually execute the SEARCH command and not a UID command.
Finally, try building your search query slowly. The following commands worked for me:
tag UID SEARCH FROM "def#gmail.com"
tag UID SEARCH OR FROM "def#gmail.com" FROM "abc#gmail.com"
tag UID SEARCH OR OR FROM "def#gmail.com" FROM "abc#gmail.com" FROM "blah#hotmail.com"
tag UID SEARCH OR OR OR FROM "def#gmail.com" FROM "abc#gmail.com" FROM "blah#hotmail.com" FROM "dah#bah.com"

Related

Searching Microsoft Graph api with spaces in the name

I'm using Microsoft Graph to do a search on the displayName for a substring of the name. The $search="displayName:MySearchTerm" format works perfect. But trying to search on the displayName with a space in the term doesn't seem to work as expected.
Using the sandbox application here
https://developer.microsoft.com/en-us/graph/graph-explorer?request=groups?$expand=members&method=GET&version=v1.0
If I use the following query format:
https://graph.microsoft.com/v1.0/groups?$search="displayName:Product vi"&$select=displayName&$orderBy=displayName
how can I get it to return only those records that have the term Product vi in the displayName field.
It shouldn't return any records in the sandbox because the term Product vi does not appear exactly in any part of the displayName but it currently returns the record "displayName": "Video Production"
I've tried the following without success:
$search="displayName:"Product vi""
$search="displayName:\"Product vi\""
$search="displayName:\\"Product vi\\""
$search="displayName:\\\"Product vi\\\""
$search="displayName:'Product vi'"
$search="displayName:\'Product vi\'"
The $filter format is no good to me as it doesn't search the middle of the displayName for the string.
How do I format the url to get the desired results if it is even possible?
The trick is to use comma instead of the space in $search clause.
https://graph.microsoft.com/v1.0/groups?$search="displayName:Product,vi"&$select=displayName&$orderBy=displayName
If $search clause contains "displayName:Product,vi" then Graph API will search on displayName for "Product vi"
It can require a special request header:
ConsistencyLevel: eventual
Try with %22
instead of
%20
good code...

How to see list of authorized users google sheets

I have a spreadsheet that I've authorized a few users to access. Now I want to poll these people regarding a change. How can I obtain a list of those people (e-mail addresses) that have been given access?
Since I'm here, how can I determine what access each has?
Thanks
You want to retrieve the editors and viewers list of a Google Spreadsheet.
I think that in order to achieve your goal, it is required to be used a script. In this answer, I would like to propose the method for achieving your goal using Google Apps Script.
Sample script:
Please copy and paste the following script to the script editor of Google Apps script. And run the function of myFunction. When the authorization screen is shown, please authorize the scopes. By this, the script is run.
function myFunction() {
var spreadsheetId = "###"; // Please set the Spreadsheet ID.
var ss = SpreadsheetApp.openById(spreadsheetId); // or SpreadsheetApp.getActiveSpreadsheet()
var res = {
owner: ss.getOwner().getEmail(),
editors: ss.getEditors().map(e => e.getEmail()),
viewers: ss.getViewers().map(e => e.getEmail()),
};
console.log(res)
}
If you use the container-bound script of Spreadsheet, you can use SpreadsheetApp.getActiveSpreadsheet() instead of SpreadsheetApp.openById(spreadsheetId).
Result:
When above script is run, the following result is returned.
{
"owner": "### your email address ###",
"editors": [
"### your email address ###",
"### user's email ###",
"### user's email ###",
],
"viewers": [
"### your email address ###",
"### user's email ###",
"### user's email ###",
]
}
References:
getOwner()
getEditors()
getViewers()

Emails could be marked as read and left in the mail server, new issue couldn't be created automatically in Redmine

I spent over a week to build an auto ticket submission system based on Redmine (Bitnami 3.0.0), but there is one problem confused me a lot and I am struggling it till now.
Here is my background:
Need to build an auto ticket submission system and all tickets auto created via one email account.
Firstly, I create one Gmail account used for ticket creation email address, let's say it "abc#gmail.com" and my company email address is "sender#abc.com". All tickets could be created automatically without an issue from sender#abc.com to abc#gmail.com
sender#abc.com --> abc#gmail.com --> ticket auto creation succeed (via abc#gmail.com to create ticket)
However, to avoid secure issue, an company email account which named ticket#abc.com needs to be used instead of the gmail one. ticket#abc.com is a shared mailbox. Here are my test results.
sender#abc.com --> ticket#abc.com --> ticket auto creation failed (via ticket#abc.com to create ticket)
ticket#abc.com --> sender#abc.com --> ticket auto creation failed (via sender#abc.com to create ticket)
abc#gmail.com --> sender#abc.com --> ticket auto creation succeed (via sender#abc.com to create ticket)
What I can see from OWA webpage, if failed, all new emails had been gone through and "marked as read" and then left in the mail server.
Here is my command:
rake redmine:email:receive_imap unknown_user=accept no_permission_check=1 RAILS_ENV="production" host=imap.abc.com port=143 username=ticket password=xxx project=projectname allow_override=project,subject,status,tracker,priority,category,author,desc,issue --trace
However, there is no any error from the trace
C:\Bitnami\redmine-3.0.0-0\apps\redmine\htdocs>rake redmine:email:receive_imap unknown_user=accept no_permission_check=1 RAILS_ENV="production" host=imap.abc.com port=143 username=ticket password=xxx project=projectname allow_override=project,subject,status,tracker,priority,categ
ory,author,desc,issue --trace
DL is deprecated, please use Fiddle
** Invoke redmine:email:receive_imap (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute redmine:email:receive_imap
C:\Bitnami\redmine-3.0.0-0\apps\redmine\htdocs>\
A debug level has been turned on as well. But here is only I could find from the production.log, only I could see is "Message xx can not be processed", nothing more...
Receiving message xx
[1m[36mSetting Load (0.0ms)[0m [1mSELECT `settings`.* FROM `settings` WHERE `settings`.`name` = 'mail_from' ORDER BY `settings`.`id` DESC LIMIT 1[0m
[1m[35mUser Load (1.0ms)[0m SELECT DISTINCT `users`.* FROM `users` INNER JOIN `email_addresses` ON `email_addresses`.`user_id` = `users`.`id` WHERE `users`.`type` IN ('User', 'AnonymousUser') AND (LOWER(address) IN ('sender#abc.com')) ORDER BY `users`.`id` ASC LIMIT 1
Message xx can not be processed
Then, I checked C:\Bitnami\redmine-3.0.0-0\apps\redmine\htdocs\lib\redmine\imap.rb
if MailHandler.safe_receive(msg, options)
logger.debug "Message #{uid} successfully received" if logger && logger.debug?
if imap_options[:move_on_success]
imap.uid_copy(uid, imap_options[:move_on_success])
end
imap.uid_store(uid, "+FLAGS", [:Seen, :Deleted])
else
logger.debug "Message #{uid} can not be processed" if logger && logger.debug?
imap.uid_store(uid, "+FLAGS", [:Seen])
if imap_options[:move_on_failure]
imap.uid_copy(uid, imap_options[:move_on_failure])
imap.uid_store(uid, "+FLAGS", [:Deleted])
end
end
Everytime, if mails sent between company email addresses, the MailHandler.safe_receive(msg, options)is false. But if mails sent from gmail to company email address, this is true.
I really have no idea what cause it happen and is it the issue from my company mailbox configurations? My company is using Exchange Server.
Is there any way could solve this issue or any work around? Thank you so much!
=============
Additional:
I find out the reason caused this issue is because my Email Content-Type is "text/html", if "text/plain", no any issue.
Below are my new findings:
But it looks like Redmine supports HTML Only email and I have no idea why my email cannot be processed.
Here is the code snippet from "mail_handler.rb"
parts = if (text_parts = email.all_parts.select {|p| p.mime_type == 'text/plain'}).present?
text_parts
elsif (html_parts = email.all_parts.select {|p| p.mime_type == 'text/html'}).present?
html_parts
else
[email]
end
parts.reject! do |part|
part.attachment?
end
#plain_text_body = parts.map do |p|
body_charset = Mail::RubyVer.respond_to?(:pick_encoding) ?
Mail::RubyVer.pick_encoding(p.charset).to_s : p.charset
Redmine::CodesetUtil.to_utf8(p.body.decoded, body_charset)
end.join("\r\n")
# strip html tags and remove doctype directive
if parts.any? {|p| p.mime_type == 'text/html'}
#plain_text_body = strip_tags(#plain_text_body.strip)
#plain_text_body.sub! %r{^<!DOCTYPE .*$}, ''
end
Even though my email is "Content-Type: text/html; charset=us-ascii", it still cannot be processed. Tested by Outlook 2010
Is there anyone has the similar issue or solution for that? thank you!
I had the same problem and was focused many days on Redmine without finding any solution.
Finally, I decided to look at my Exchange Online parameters and modified my IMAP email account used for Redmine.
Here is the link to connect to your Exchange Online with Powershell:
http://community.office365.com/en-us/f/158/t/158857.aspx
Of course, if you don't use this Exchange release, you should be able to access to it directly.
Here is the line to execute in Powershell to convert emails to plain text instead of default HTML:
Set-CASMailbox xxxx#yyyyyy.zz -ImapMessagesRetrievalMimeFormat TextOnly -imapUseProtocolDefaults $false
Then you can check the result with the following line:
get-casmailbox xxxx#yyyyyy.zz | format-list imap*
I hope it will help you to solve your problem!

Clicks on OpenGraph links in timeline fail to authenticate with "Error validating verification code"

I'm trying to authenticate users coming to my site from a click on an opengraph action in facebook.
I've generate the action successfully with the following code. This
goes out to my timeline successfully. So far, so good.
require 'cgi'
client_id ="CLIENT_ID"
client_secret = "CLIENT_SECRET"
recipe = "http://foodonthetable.shadr.us/recipes/1007-spanish-chicken-and-rice"
access_token = "LONGACCESSTOKEN"
# PUBLISH
result = `curl -F access_token=#{access_token} -F recipe=#{recipe} https://graph.facebook.com/me/foodonthetable_mrh:plan_to_cook`
puts result
When I click on the link in the timeline, I'm taken to the following URL. This is where
I start having issues. Basically, I want to recognize the user coming in
through this link and log them in (or create a new user). I have
authenticated referrals turned on, and I'm receiving the code parameter as
expected.
http://foodonthetable.shadr.us/recipes/1007-spanish-chicken-and-rice?fb_action_ids=384156608318085&fb_action_types=foodonthetable_mrh%3Aplan_to_cook&fb_source=timeline_og&action_object_map=%7B%22384156608318085%22%3A10151004406923956%7D&code=AQAPExNw7MHkxcLTEi5L24iD79pVa-WYxyhBA_bhdWLCM0PCGDuPjh1WqmAyd3_O3_LSjYzPawrinHNP3nv9BCMB_XuTnr8De8xQ2AwXqCaeHUzZUPm2MPyQ_eodOC9-YtjkvXm_PzRX3JG58khalT3AJjVuZvKHn5hWGDSohXLRbHGxW-vOg_Whm3mt_WUkdd0#_=_
However, when I try to get the auth_token using this code, I'm not able to.
I've tried using a couple of different versions of the redirect_uri thinking
that might be the problem (based on other posts) but nothing seems to work.
redirect_uri = "http://foodonthetable.shadr.us/recipes/1007-spanish-chicken-and-rice"
redirect_uri = "http://foodonthetable.shadr.us/facebook_connect/connect"
code = "AQAPExNw7MHkxcLTEi5L24iD79pVa-WYxyhBA_bhdWLCM0PCGDuPjh1WqmAyd3_O3_LSjYzPawrinHNP3nv9BCMB_XuTnr8De8xQ2AwXqCaeHUzZUPm2MPyQ_eodOC9-YtjkvXm_PzRX3JG58khalT3AJjVuZvKHn5hWGDSohXLRbHGxW-vOg_Whm3mt_WUkdd0"
result = `curl -F client_id=#{client_id} -F redirect_uri=#{redirect_uri} -F client_secret=#{client_secret} -F code=#{code} https://graph.facebook.com/oauth/access_token`
puts result
No matter what I do here, I always get the following error:
{"error":{"message":"Error validating verification code.","type":"OAuthException","code":100}}
Any help would be appreciated.
This does fix it.
redirect_uri = request.url.split('&code=').first

Fetchin Content in IMAP repeating issue

I am Fetching content of the mail through IMAP, but I am not able to properly Fetching content.
My flow is like.
1> Connecting to IMAP.
2> Authenticate user.
3> Retrive the No of Folder.
4> Select Folder.
5> Retrive list of UID of Selected Folder.
6> And Fetching mail content according to UID which already selected folder.
But I ma not able to fetching a proper content beacause the things is that let say I have 6 mail and I am retriving those mail UID.
And passing to one by one into the FETCH Command; but the FECTH Command is retriving one last mail content every time.
I don't know why it's happening. my FETCH Command is like this.
byte[] commandBytes = System.Text.Encoding.ASCII.GetBytes(("$ FETCH " + UID + " (BODY[HEADER.FIELDS (SUBJECT FROM DATE)])" + "\r\n").ToCharArray());
Is there any solution then let me kwon..
Thanks..!!
If you're passing a UID to the server, you must use UID FETCH, not FETCH:
byte[] commandBytes = System.Text.Encoding.ASCII.GetBytes(("$ UID FETCH " + UID + " (BODY[HEADER.FIELDS (SUBJECT FROM DATE)])" + "\r\n").ToCharArray());

Resources