I want my debian/proxmox system to be enabled to send mails to my nethserver mailserver. How can this be enabled? For examle I’d like that mdadm of ProxMox Host is able to send a mail if one disk of the mirror is kicked out of the raid. On my gentoo I have configured this successfully in ssmtp package, but this is not possible with debian/proxmox.
I would be glad, if someone could point me to the right direction.
I thought postfix is a to big beast for just relaying mails to a real mailserver, so I thought it would be easier to use ssmtp, but this package is unmaintained in debian, but ok, so I try to configure postfix as it is installed anyway, so thanks for the links. I tried to configure it analog to the second link. I am not using my nethserver mailserver yet, as I did not open apropriate port yet (587), so I use my personal emailaccount on an external hoster for first test. Apparently I have to change the from origin, as here is what I get:
postfix/smtpBC3E017FAC0: to=elleni@domain.com, relay=smtp.domain.com[ip.ad.re.ss]:587, delay=0.23, delays=0.13/0.01/0.08/0.01, dsn=5.1.0, status=bounced (host smtp.domain.com[ip.ad.re.ss] said: 550 5.1.0 root@proxhostname.domain.com sender rejected, invalid domain (430) (in reply to MAIL FROM command))
Jun 16 23:08:59 proxhostname postfix/cleanup[23757]: E8A6B17FAC2: message-id=20200616210859.E8A6B17FAC2@proxhostname.localdomain
Jun 16 23:09:00 proxhostname postfix/bounce[23760]: BC3E017FAC0: sender non-delivery notification: E8A6B17FAC2
Jun 16 23:09:00 proxhostname postfix/qmgr[22758]: E8A6B17FAC2: from=<>, size=2367, nrcpt=1 (queue active)
Jun 16 23:09:00 proxhostname postfix/qmgr[22758]: BC3E017FAC0: removed
Jun 16 23:09:00 proxhostname postfix/smtp[23759]: E8A6B17FAC2: to=root@proxhostname.domain.com, relay=smtp.domain.com[ip.ad.re.ss]:587, delay=0.31, delays=0.06/0/0.12/0.14, dsn=5.1.1, status=bounced (host smtp.domain.com[ip.ad.re.ss] said: 550 5.1.1 root@proxhostname.domain.com recipient rejected (510) (in reply to RCPT TO command))
Jun 16 23:09:00 proxhostname postfix/qmgr[22758]: E8A6B17FAC2: removed
The “from” field is very important - since spamming is so common, but you can also change that in the GUI.
If sent by script, you would need to set that in postfix - or your script.
So I don’t know how to test the configuration to get a mail sent successfully. Thats why I thought I have to change that somewhere in postfix config, so I am searching for the where and how
Thanks! Understood, so this works if I define the sender the test is successfull and mail delivered. Now the only missing bit remaining is how do I tell postfix, that it shall always use a certain emailadress as from and to for systemmails to root? I understand, that setting the sender in proxmox gui should and probably will work, but what I want to acheive is that for ex. mdam will send mail as soon as the raid gets degraded. Have you done that ? Would you recommend to search for defining sender within mdam or directly in postfix set the mailadress for root somehow so that every service for ex. a cron job automatically sends to this address when sending mail to root? Probably some alias I have to set somewhere… digging the net
I have done this and similiar before, but always from my own scripts, where the sender was a variable set at the top of the script, same as the recipient.
You could also (simpler) create a mail-rule for root, and forward messages using a legit user (not root) to an external mail account. Mailsieve is your friend…
I see, I would rather like to have postfix configured that way that mails to root are always sent to a defined emailadress. I thought, I found something and added the follwing in main.cf:
Well I dont get it. I mean, I am using a legit mailadress, my personal one in fact. I will create a mail, once I got it working. The problem is how do I tell postfix that root’s mails should be sent to this address. Creating a A record I will be able to do once I transfer this solution to nethserver mail, where I am able to modify the dns. But for now, I am trying with an ordinary mailserver. It could be gmail.com mailserver or something, so I cannot create any zone to workaround it. I just need to find out, how I can tell postfix that it shall always use from and to address xy.
I understand, but before trying on my domain where I can modify dns, I’d rather try on the external mailserver to rule out errors on my nethserver mailserver config, for ex. right now, I dont have submission port 587 opened yet.
I tried with following line added in aliases, but no luck.
root: elleni@domain.com
Some further digging revealed the following. Apparently there are two ways to forward mails. With aliases and also with .forward file in user’s home. There I found the following in /root/.forward:
|/usr/bin/pvemailforward
So I went and created a backup job with email notification. As long as I configured a legit mailadress in datacenter/options/email from address in ProxMox the mail is delivered correctly.
Unfortunately this does not work for mdadm on the same host, as I configured the same legit emailaddress for mailaddr and mailfrom in /etc/mdadm/mdadm.conf. I also get an email, but it looks like this:
The correct mail is attached, with configured mailaddr and mailfrom, but the mail I get says:
This is the mail system at host proxmoxhostname.localdomain. I’m sorry to have to inform you that your message could not be delivered to one or more recipients. It’s attached below. For further assistance, please send mail to postmaster. If you do so, please include this problem report. You can delete your own text from the attached returned message. The mail system elleni@domain.com: host smtp.domain.com[ip.ad.re.ss said: 550 5.1.0 root@proxmoxhostname.localdomain sender rejected, invalid domain (430) (in reply to MAIL FROM command)
This is an automatically generated mail message from mdadm running on hrs A TestMessage event had been detected on md device /dev/md0. Faithfully yours, etc. P.S. The /proc/mdstat file currently contains the following: Personalities : [raid1] [linear] [multipath] [raid0] [raid6] [raid5] [raid4] [raid10] md0 : active raid1 sda2[0] sdb2[1] 1928159232 blocks super 1.2 [2/2] [UU] bitmap: 8/15 pages [32KB], 65536KB chunk unused devices:
Ok, as I have a second proxmox I restarted with a clean postfix configuration, and additionally I found a post, which finaly solved all my problems. The smtp_header_checks file along with installation of postfix-pcre finally made everything work on both of my proxmox nodes, but I only tested the mailnotification for mdadm degraded raid state, and not yet on the non zfs node. General email notification for ex. after a backup works fine on the zfs node too, but I would like to ensure that zfs zed will mail me if one disk goes south.
I tested by setting one disk to faulty on the non zfs proxmox and I immediately got my email notification. One last thing I’d like to know on this topic is is the follwoing. As having had experience with mdadm, I was not afraid to set one disk to faulty. After that I knew removing it from raid and adding it back the sync will start and so it did.
Now I’d like to know, how I could test the same functionality in zfs. Being new to zfs, I thought, better ask then sorry