How to read email from command line in linux? - linux

I have a server with roundcube installed in it. I tried sending email into it from external email with my username#servername. It turns out that I was not able to read emails (no email pops up in inbox) but when I send email to some external email address from roundcube then it works fine. I was wondering if there is any command-line code to read any emails that any user #server receives.

Yes. There is a nearly 30 yrs old 'mail' command. But an
apt-get install alpine
helped a lot as well.

Related

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.

Add unix user to postfix maillogs

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.

The location of received email in Debian

I installed exim4 on my debian machine. And I've successfully send an email to my Gmail address. But when I send an email from my Gmail to my linux machine. I dont know how can I read it and where is the location of this email.
By default all e-mail goes to /var/spool/mail/$USERNAME
where $USERNAME is the username you're using.
If you don't have a mail reader installed, you can try to use
mailx
at a terminal but it's interface is hard to use (basically p, n, and other keystrokes) for begginers. Another, better option to be used at a terminal is
mutt
Cheers

How do i send a script file using mailx to another user on the Host pc on Linux

i'm using fedora and i'm wanting to send a file using mailx to another user on the host PC, how would i go about doing this? i only know how to send to a email address
i'm new to this, thanks
i only know how to send to a email address
Then you are nearly there. Send it to username#localhost where username is his login name.

Resources