Which application determine or set the maildir in a mail server? - email

My question is about mail server configuration with postfix (smtp) and dovecot (imap,pop3), both of these application have to see the same path to the maildir, for example /var/vmail/my_domain/user/Maildir. So, which application determine or set the maildir or the path to it?

In your case BOTH of applications sets the maildir path, but postfix define it for writing during local delivery, while dovecot define it for reading during POP/IMAP interactions.
This is an example of the bad configuration, widely spreaded over the numbers of howtos and manuals. You should never perform local delivery from the MTA like postfix or exim. You have to use LDA functionality from your POP/IMAP server like dovecot instead.
When you invoke dovecot's dovecot-lda for LDA then the single dovecot.conf is used to define storage path and the single service have r/w access to the sorage so you can secure storage by 600 permissions.
You can refer to the dovecot's wiki to know how to move LDA functionality from the postfix to the dovecot https://wiki.dovecot.org/LDA/Postfix

Related

What is the easiest mail server setup for piping incoming mails to scripts *only*?

I want to set up a ticketing system (osTicket) on a centOS server that generates tickets from incoming e-mails.
osTicket can query mailboxes, but it also provides an API / scripts for piping. Is there a recommended way to setup a (lightweight) mailserver to pipe incoming emails to the script? I do not need actual mailboxes for users.
It's been a while since I did any work on a mail server, but it seems to me that I would only need to set up an MTA for this, and no MDA, correct?
My fallback is to set up POP3/SMTP inboxes elsewhere and query from osTicket. Easy as that would be, the local MTA setup seems cleaner to me.
Consider using remote mailbox accessible via IMAP with IMAP IDLE command support.
It will allow you to get "near real time" delivery to pipe without burden of configuring properly your own SMTP server.
[AFAIR IMAP IDLE is supported e.g. by gmail]
You may use fetchmail with custom procmail script as mda (no need for local SMTP/MTA server).
Using procmail (as "man in the middle) is not strictly necessary but your it will allow you to easily run filtering before delivery to the ticket system (e.g. anti-spam + anti-virus).

fail2ban configure third-party email server

I'm using fail2ban on Google Compute Engine where I can't install sendmail or other email servers and I would to set sendgrid as email server.
In jail.local there is this config:
destemail = myemail#myhost.it
mta = mail
Where can I set the host, user, password to send emails via sendgrid.com?
I think that fail2ban uses the machine mail command to send email, thus it is using the machine mailing daemon. If you look at this snippet:
# Option: actionstart
# Notes.: command executed once at the start of Fail2Ban.
# Values: CMD
#
actionstart = printf %%b "Hi,\n
The jail <name> has been started successfully.\n
Regards,\n
Fail2Ban"|mail -s "[Fail2Ban] <name>: started on <fq-hostname>" <dest>
that is taken from here (fail2ban sources on github), you can see that a message of fail2ban is piped to the mail command (in Debian based distribution this is installed via the mailutils package). Since I think your problem is that you cannot use or configure this mail command (which means configuring the mail server), you may think to write a very simple mail binary (in the language you prefer), with a pretty similar interface that may use something like the Gmail App Script to send the email, or even Gunmail or Sendgrid to actually send an email from that machine (with a POST request through the REST Api? Do they allow you?), and add this custom binary to the $PATH of the user that runs fail2ban.
Edit: There is a page in the Google compute documentation related to Send Grid. Also according to this you cannot use sendmail: the ports are closed.
Google Compute Engine does not allow outbound connections on ports 25, 465, and 587. By default, these outbound SMTP ports are blocked because of the large amount of abuse these ports are susceptible to. In addition, having a trusted third-party provider such as SendGrid, Mailgun, or Mailjet relieves Compute Engine and you from maintaining IP reputation with your receivers.

Exim: read local mail with simple mail client like unix `mail`

EDIT: I have not used the wrong mail reader, but my exim was no configured correctly. So I go and check that first. I used exim quite out-of-the-box in gentoo linux.
Original Question:
It's a bit hard to google, since the word mail means much more than just the unix command mail.
I want to run a local exim that spools most of the mail just locally. I want to read that mail with something like mail from commandline.
Now, exim does not use /var/spool/mail and not the same spooling format, so mail just finds no new mails.
So my question: how should I combine a simple mail client with exim, and which simple mail client is able to do so?
Check your exim.conf file to see which transports are delivering local messages. It will look something like this (from an Ubuntu machine):
mail_spool:
debug_print = "T: appendfile for $local_part#$domain"
driver = appendfile
file = /var/mail/$local_part
delivery_date_add
envelope_to_add
return_path_add
group = mail
mode = 0660
mode_fail_narrower = false
Also go look in your mail logs, somewhere under /var/log. Find where it's actually delivering the messages by finding what transport it's using to deliver them. It will be in the delivery line (the one containing "=>" to the local user) and will be of the format T=transport_name. You can look at that transport definition in exim.conf to determine where it's delivering them if you can't figure out where the emails are being delivered from the log messages.
Alternative: Every distro has the mutt MUA available as well (CentOS installs it by default). You might find it easier to install and configure mutt to read the mail spool wherever it is being delivered, than to try and re-work whatever custom changes your distro made to exim and its local mail spool delivery. Common delivery locations are:
/var/mail/$USER
$HOME/Maildir/
$HOME/.maildir/
Note that the presence of a trailing slash when defining mail spools usually indicates that the mailbox is in Maildir++ format (i.e. one file per message). The absence of that slash usually indicates that the mailbix is in mbox format (i.e. one big file).

File Distribution via SMTP: How to do the receiving side?

I need to setup a file distribution system between different sites of a WAN. Files that are dropped into some input directories on the source machine should be distributed into a directory on each of the target machines at other sites. One of the requirements is that between certain sites the only allowed traffic is SMTP. There is already a daemon in place that covers the sending side by polling input directories and mailing all found files as attachments to configured addresses (was thought for human recipients originally).
How would you design the receiving side?
One could write a stripped down SMTP server that handles only this one case, strips attachments from incoming mails, and puts them into a local directory.
One could setup a full mail server with local delivery, poll the user’s inbox and try to extract files from there.
One could setup a full mail server with a configuration or procmail to directly extract attachments into a directory.
I don’t really like any of these proposals because they are all more involved than setting up a SSH or FTP server. Also I don’t have experience with setting up and administrating mail servers.
Do you have suggestions or experiences to share?
The target system is Linux/Unix, but if you know something platform independent I’d like to hear, too.
The most suitable way is to set up an ESB with SMTP support, like ServiceMix or Mule. Mule is more straight-forward to get started with.

Mail server with smart-host

I want to create a mail server, but my ISP does not allow reverse-IP record, so I ordered a VPS with such function. But I want use VPS only as a relaying server and my own server as an actual mail server (so it should have things like web-mail, and some other). I did not find any guides, but looks like VPS will be called a "smart-host". So I installed Axigen on my server, but it requires login and password for connecting to a smart-host. I tried to use postfix for relaying but I did non figure out how to properly configure it. What are my options?
Thank you!
To securely enable postfix as a mail forwarding server, you'll have to enable and configure SASL authentication. The postfix SASL README has all the details. I suggest dovecot as the backend, as it's the simplest to setup. After that, just create a new system user (adduser mail-forwarding) and configure Axigen to use that user for forwarding.
If I understand correctly, your goal is to forward outgoing mail from your local server to the VPS while incoming mail should be stored on the local server. This is possible, but not necessarily simple. Mail needs to be handled differently depending on how it reaches your local server, otherwise you might end up with a mail loop, with your servers playing pingping using mail sent back and forth.