postfix senders name partially missing due to comma - email

All user names in /etc/passwd are formatted "Lastname, Firstname"
E.G
~# getent passwd jbloggs
jbloggs:*:1367239261:1367200513:Bloggs, Joe:/home/jbloggs:/bin/bash
When an email is sent by Joe Bloggs (or Bloggs, Joe as listed in the passwd file) recipients of the email see the email coming from:
Bloggs <jbloggs#comany.com>
it should be:
Bloggs, Joe <jbloggs#comany.com>
When I remove the comma for Joe in passwd I see:
Bloggs Joe <jbloggs#comany.com>
This seems like a simple settings change but despite my searches I cannot find how to correct this.
Any help appreciated.

Related

getting the "title" between the names

The name I'm working on is formatted like this:
King, Mr. Jay Thomas
Smith, Miss. Jane
How do I get the middle title part only using Postgres?
I'm a noob so this is definitely wrong:
SELECT position('%#," #"%#' for '#') AS TITLE
FROM titanic;`
You could use SUBSTRING with the regex pattern \w+\.:
SELECT SUBSTRING(title from '\w+\.')
FROM titanic;

Email: universal quoted text delimiter

I need to form a reply to an email that will have users input + some delimiter + body of the message the user is replying to.
What I can't seem to figure out is a way to separate the user message from the quoted text so that most mail clients would pick it up as a valid delimiter.
Something like this:
BAR
----Original Message----
FOO.
Replies are typically prefixed with ">", for example:
BAR
Joe Foo wrote on <date>:
> FOO
> More FOO
A forwarded message is included as you suggest above, for example:
BAR
-------- Forwarded Message --------
Subject: whatever
Date: <date>
From: Joe Foo
FOO
More FOO
There are no "standards" for any of this, so different mailers will behave differently, and you might need to experiment with the mailers you care about most to get the effect you want.

Wrong Email Error message - By Sendmail unix

Does sendmail command returns any errors if we use wrong email id with correct e-mail id pattern?
If it is not how to identify if e-mail is delievered?
Yes Nitin, unix does give an output if the email remains undelivered. you can check in /var/spool/mail/home_dir
For example
mailx correct_addr#domain.com -s "Success Tested" correct_addr#domain.com < /tmp/dileep/test.txt
correct_addr#server:
you will see the prompt back to you, else look below
mailx correct_addr#domain.com -s "Success Tested" wrong_addr#domain.com < /tmp/dileep/test.txt
You have mail in /var/spool/mail/home_dir
correct_addr#server:
you can go and check the error message, if you would like to check or automate, you can monitor the home_dir for any mail delivery failures and send one email to you will all the details attached to the email and find out the wrong addresses.
NOTE: This works the same way for To and From addresses as well.

print column and count the string

I have large column wise text file with space demlimited
Name subject Result
John maths pass
John science fail
John history pass
John geography pass
Jack maths pass
jack history fail
kelly science pass
kelly history pass
I want to count for each name (it is long name list, each name should be appear only once), how many of them pass. For eg. For John, he passed 3 and similarily for Jack he passed 1. It should print the result as
Name Passcount
John 3
Jack 1
Kelly 2
Can anybody can help with awk or perl script. Thanks in advance
You can try something like this -
awk '
BEGIN{ print "Name\tPasscount"}
NR>1{if ($3=="pass") a[$1]++}
END{ for (x in a) print x"\t"a[x]}' file
Test:
$ cat file
Name subject Result
John maths pass
John science fail
John history pass
John geography pass
Jack maths pass
jack history fail
kelly science pass
kelly history pass
$ awk 'BEGIN{ print "Name\tPasscount"} NR>1{if ($3=="pass") a[$1]++}END{ for (x in a) print x"\t"a[x]}' file
Name Passcount
Jack 1
kelly 2
John 3

Move emails with procmail if it matches from sender

as im using different email clients to read/send my mails i want to setup procmail to move my emails to a the folder which is normally done by Thunderbird filter feature.
I know that i can do it by using the following code for procmail in my email users .procmailrc file:
:0:
* ^From:.test#host.name.com
myfolder
But i have a list of about 50 email adresses which i would like to move to that specific "myfolder".
So by using
:0:
* ^From:.first#mail.com
* ^From:.second#mail.com
jimsmail
doesnt help, because procmail interprets them by using the AND operater. So the code above would be true if From is first#... AND second#..., which will never be true.
So how do i use the OR operator.
Actually i have a simple text file where all email adresses are.
Would be cool to have a feature where procmail ready in that file and checks if From matches with at least one of the lines in the file, the moves email to "myfolder".
Something like
:0:
* ^From:file(email.txt)
myfolder
Does anybode if this or something similar is possible.
I dont want to add these 3 lines 50 times in my procmailrc file.
Procmail uses regexps, so you can separate addresses with the | character.
:0:
* ^From:.((first|second|third)#mail.com|(fourth|fifth)#othermail.com)
myfolder
would work. Could get a little messy with fifty all on one line, mind...
I found the solution.
With this solution im able to use a simple email text file holding all email addresses in each in one line.
The code in my .procmailrc is as follows:
EMAILFILE=/path/to/my/emailfile
FROM=`formail -xFrom: | sed -e 's/ *(.*)//; s/>.*//; s/.*[:<] *//'`
:0
* ? fgrep -qxis $FROM $EMAILFILE
myfolder