Postfix Header Checks - header

Good morning everyone, I'm trying to create a rule of changing the FROM header on sent email.
My need is to change the FROM of all the mails that come from a specific mailbox (software#domain.com) and that have in CC the mail of a specific store (store04#domain.com).
For Example the mail sent to SMTP Server will have as FROM:software#domain.com, as CC:store#domain.com and as TO: customer#company.com, the mail that will have to exit need to have header with FROM: store#domain.com and TO:customer#company.com only.
I already tested some rules in header checks config (/etc/postfix/header_checks) but without any working results.
Thanks in advance.

Something like the below might work:
if /^From: software#domain.com$/
/^From: software#domain.com$/ REPLACE From: store#domain.com
/^CC: store#domain.com$/ IGNORE
endif
I haven't tested this and I am by no means a Postfix expert, but from my reading of http://www.postfix.org/header_checks.5.html, I think I have got all you need.

Can't comment to Jacobs answer but want to add that http://www.postfix.org/header_checks.5.html states
Note: do not prepend whitespace to patterns inside if..endif.

Related

URN Filter to Ignore Emails

I am using UiPath's Get Outlook Mail Messages component to obtain emails.
My only request has been to ignore any emails that are Replies, so contain "RE:"
In my email filters I had tried the below:
#SQL=urn:schemas:httpmail:subject NOT LIKE 'RE%'
Unfortunately, I receive the error "Get Outlook Mail Messages: Cannot parse condition. Error at "#SQL=((urn:schemas:httpmail:subject NOT ...".
When I try the filter: `
#SQL=urn:schemas:httpmail:subject LIKE 'RE%'
I am able to obtain all emails that contain 'RE:' but as specified, I want to omit these.
Would anyone be able to advise how to Omit these emails? I need to obtain every other email in the Inbox so makes more sense to just ignore the Replies.
Thanks,
Your code is very close to being correct. The NOT keyword does work, just the placement is incorrect, unlike normal SQL where the NOT would be before the LIKE, in this case it would come before the field name.
So rather than:
#SQL=urn:schemas:httpmail:subject NOT LIKE 'RE%'
It would be:
#SQL=NOT urn:schemas:httpmail:subject LIKE 'RE%'

EWS SearchFilter.ContainsSubstring to filter on Sender Email Address

I'm trying to filter emails on Exchange Web Services using SearchFilter.ContainsSubstring as follows:
sfilter = New SearchFilter.ContainsSubstring(EmailMessageSchema.Sender, EmailAddress, ContainmentMode.Substring, ComparisonMode.IgnoreCase)
MailItems = service.FindItems(Folder.Id, sfilter, view)
Unfortunately this doesn't work, and I don't want to use Queries, because I can't guarantee that I can use features of Exchange Server 2013.
Composing a variety of requests in Fiddler, I can observe that if I remove the last character of the email address, then the filter works, remove the first character instead, works - put them back, broken.
So perhaps it's pedantic, and it has to be a true substring to qualify, so if I change the Containment mode to FullString - it doesn't work, so I can't do anything like a collection with Substring OR FullString.
It looks like I'll be able to do (Substring with last char missing AND Substring with first char missing), but it surely can't be that broken can it?
What can I do to get this to work?
Note that my code is in VB.NET, but I can't imagine that this is the problem.
Cheers,
Mark
I worked out that the IsEqualTo filter works with From/Sender, and it doesn't care about case-sensitivity issues, so it's probably what I should have tried to begin with.
The code to match an email address is:
sfilter = New SearchFilter.IsEqualTo(EmailMessageSchema.From, New EmailAddress(Message.FromAddress))
MailItems = service.FindItems(FailureFolder.Id, sfilter, iv)
I still don't know how to find all emails from users at the same domain though.
More Info:
I really needed to filter by Sender Domain and did that by pulling the entire folder contents down and filtering in .Net code. Even that causes problems.
Basically to keep things quick and tight, I tried to pull all the data with a PropertySet:
New PropertySet(BasePropertySet.IdOnly, EmailMessageSchema.Sender)
Filtering still didn't work, yet email addresses still showed in my list of items view. Well it turns out that the value of Message.Sender contains some kind of ActiveDirecty path in it until you call LoadPropertiesForItems. After LoadPropertiesForItems, it's an email address.
Note that my earlier attempt to filter at the server was scuppered because filtering would have to occur against the ActiveDirectory path style of string.
This is all highly confusing, and not at all user friendly.
If anybody has any idea on how to filter by email domain at the server, let me know!
Mark
What is your goal? Sender isn't a string property, so I'm not surprised that the results are odd with ContainsSubstring. I tried it against Office 365 and it worked, but older versions of Exchange may not be as "smart" about handling this kind of query. Depending on what you're trying to achieve, there may be a better filter.
if(emailSenderList.size() == 1) {
return new SearchFilter.IsEqualTo(EmailMessageSchema.From, emailSenderList.get(0));
}
return new SearchFilter.SearchFilterCollection(LogicalOperator.Or, emailSenderList.stream().map(em -> new SearchFilter.IsEqualTo(EmailMessageSchema.From, em)).toArray(SearchFilter.IsEqualTo[] :: new));

How to store extra header value with MailCore2?

I add an extra header value with MailCore2:
MCOMessageHeader *messageHeader = message.header;
[messageHeader setExtraHeaderValue:spamScoreString forName:#"Spam Score"];
How can I save this new header value to the IMAP server?
I have already searched for sample code and I have also read the class reference for MCOMessageHeader (which, by the way, states the wrong method name - (void)addHeaderValue:(NSString *)value forName:(NSString *)name)
editWith the help of dinhviethoa in the MailCore2 forum on GitHub (https://github.com/MailCore/mailcore2/issues/680), the question could be answered:
It is not possible to edit the header of an existing email.
However, it is possible to remove the existing message from the server and append a new message (with extra headers).

postgres fulltext index for email

I want get lei4#gmail.com by searching lei4 or gmail.com.
The first one only have token: email.
What I want is like the second one
Can we parse the email to email, asciiword and host token? any ideas will help.
I already read the tsearch2 guide, reference, etc. can't find the solution.
A simple solution would be to transform email addresses into local-part at domain-part before feeding them to the TS parser.
Since at is a stop word in english, it will be ignored.
=> select to_tsvector('english','lei4 at gmail.com');
to_tsvector
------------------------
'gmail.com':3 'lei4':1
So both lei4 and gmail.com are going to be found in this tsvector.
As a side note, lei+4#gmail.com is a valid email address and the TS parser is wrong in tokenizing it into four parts.

How to add a HTTP header field in Openacs?

I need to add a HTTP header field in the responses of a section of my site, the package instace (my section) is being viewed in a IFRAME and I want to declare a p3p field in order to be able to store cockies in IE 6/7/8 (login doesn't work well), I have an idea of how to do it in PHP and is quite simple:
<?php
header('P3P: CP="CAO PSA OUR"');
?>
but I didn't found how to do it in TCL/openacs, thanks for the help.
Based on Jim Lynch's response when you asked this question elsewhere, you just need to add it to the set of headers being produced for the page.
I'd guess that something like this is probably easiest (assuming you don't want to hard-code the contents of the header; if you did, you could simplify a little):
set cpflags "CAO PSA OUR"
ns_set cput [ns_conn outputheaders] "P3P" "CP=\"$cpflags\""
To understand it, you need to read about ns_conn and ns_set from the AOLserver docs, as well as set from the standard Tcl documentation.