Add unix user to postfix maillogs - linux

I am using CentOS 6, and postfix mail server, from postfix mail log, I want to see which Linux user has sent specific email, is it possible? How can this be done?
I need this to prevent spam from our mailservers, by one of our users. I need to figure out which user, and what script.

Since you know which email you are looking for (you should know its ID from the message header), you can simply find it in postfix mail log located in /var/log/mail.log - just look for the message ID in the log.

Related

How to send 3 mails using 3 differents gmail address to the same user using gmail api

3 différents people in my compagny need to send the same e-mail every time their is someone new.
What's the best wait to send this email using gmail
From what i saw they need to give me their password. Is there a better way ?
Yes, there is. If you write a program and it has a configuration file, then the email address can be defined in the configuration file. You can then hand over the program to the others, who will use it on their own, changing their credentials in the configuration files.

Is it possible to create a catch-all email using postfix which accepts any email address and sends an email to an external address?

Some background and my challenge:
Background
I am using Magento 2.x using a virtual machine set-up which runs on Ubuntu 16.04
Challenge
My goal is to be able to test emails sent to me from the Magento application. In an ideal situation, I would not use an extension or third-party service (although a third-party SMTP server on the linux box could work).
To achieve my goal, I need to be able to register as a customer in the Magento application with any email address (fake or real) and have the email sent to the same external email address, no matter what.
What I've done so far
I've installed postfix
I've installed Magento using luma.com as the domain (and set up my hosts file accordingly on my host machine, etc.)
I've created a linux user account called "contact"
I've configured inet_interfaces in /etc/postfix/main.cf as loopback-only
I've set mydestination to $myhostname, localhost.$mydomain, $mydomain
I've configured Magento to send its store emails from contact#luma.com
I've set up an aliases file as the following:
postmaster: root
root: contact
contact: me#gmail.com
Then I ran newaliases As far as I recall, email sends fine with this setup. Hooray!
Next, the catch-all part. For this, I've tried loads of things, and none seem to work. From the reading I've done, I've tried the following:
In /etc/postfix/main.cf, I added the following:
virtual_alias_domains = luma.com
virtual_alias_maps = hash:/etc/postfix/virtual
Next, in /etc/postfix/virtual, I encountered my first problem. As far as I understand from the reading I've done, I'm supposed to use something like:
#example.com contact
This step apparently ensures that any email sent via postfix (e.g. from the Magento application) which uses an #example.com email address would be routed to the contact linux user I created above. Then, my thinking was that the system would use the alias I set up to ultimately send out that email from contact#luma.com (via the settings in Magento) through to the external address I set up in the aliases file. This approach would theoretically allow a user to register for an account with Magento using, say, joe#example.com, and then send the associated Welcome email to my external email address.
The issue with this is that I need the system to do this for any email, not just for emails ending in #example.com
Just for sake of completeness, I'll say that before asking this question, I was most recently researching how to achieve this part of the challenge using pcre tables. I've also tried configuring something using luser_relay, but both of these things are over my head at this point, so I'm lost.
My hope is that someone can offer some guidance as to whether I'm on the right path, where I may have missed something, and ultimately, offer some advice on whether my challenge can be solved and how I might go about solving it.
Thanks for reading.

How to check a email in linux server automatically?

I have a Ubuntu 14 server, I have to assign a email account to this server, when some person write a email to this account, the server have to open this mail automatically, and check if there are a specific information, if yes some thing happen.
I suppose that the email are stored in a data base o something like that, but I not have any idea how to start.
Any Idea
First you should get confident how mail systems work in general on linux machines. A good start would be to dig into the linux documentation project, particularly the linux electronic mail administrator HOWTO, chapter 3 (how electronic mail works): http://www.tldp.org/HOWTO/Mail-Administrator-HOWTO.html#toc3
Then, you can decide to which extent you want to set up your email account on the ubuntu server (full smtp server, only mail client etc).
As #arkascha mentions in his comment, the least painful way would be to use an existing mail server and fetch mail from there. With scripts, appropriate actions can be taken once a mail has been received.
If I have correctly understood your question, what you need is a mail alias to a command.
The following may depend on the actual mail server that you use, at least it is relevant for good old sendmail, and postfix. The mail system can use an alias database (normally the file /etc/aliases) but can be hashed into a binary version. This files can contains plain aliase that simply redirect a mail address to other mail addresses, and can also contain file aliases (the mail is appended to a local file) and program aliases.
In this last case (lines are like local_address: | /path/to/program), the program is started for each mail, and it receives the message through its standard input. Read the manual for your mail server for more detailed instructions.

Filter Postfix email account with CatchAll

my boss told me to do this weird think for our client (forgive my english):
On our server with old ISPconfig (propably first version) we have an email for one site called info#domain.com and it's set up to catch all emails to this domain. Our client downloads all emails from there and then sorts them by email name. They only have like three email adresses that they want (for example: desk#domain.com, boss#domain.com, assistant#domain.com). However among emails to these mentioned adresses there are thousands of spam emails sent to whatever#domain.com and our client doesn't want to download these.
My question is: How can I setup postfix for a info#domain.com with CatchAll to keep only emails sent to these three mentioned adresses and delete the others?
P.S.
I don't need another and smarter workaround because our client wants his emails handled exactly this way
Thank you for your advice!
It sounds like what you really want are aliases, not a catch-all - i.e. remove the catch-all from info#domain.com, then make desk#domain.com, boss#domain.com, assistant#domain.com aliases of info#domiain.com. This will make is so that mail sent to any one of these four addresses will be routed to the mailbox for info#domain.com, and mail sent to any_other_address#domain.com would be undeliverable. See http://www.postfix.org/aliases.5.html.

How to access some email, and print a specific mail's message body?

I have an email address email_reports#coldmail.com, on which some reports are received daily. How can I access that mail through a terminal, find a specific mail that I need (say, check the headers or the body for string DEBUG: Daily Data Report), and print out it's body to a file in a single piped command? I have Ubuntu 12.04 LTS, and the standard mail command, as well as mutt. I've tried searching for such functionality online, but all I've managed to find is guides on how to set up various mail agents, but not to process emails in a script-like fashion.
See http://harrybailey.com/2009/02/send-or-pipe-an-email-to-a-php-script/ for an excellent article on how to pipe incoming mail to a script. This technique can be used to pipe incoming mail to just about any kind of script, be it php, perl, python, etc.

Resources