Logs for e-mail notifications

skyfall

New Member
Sep 23, 2024
3
0
1
Hi,

today I was wondering why I did not receive an e-mail for a failed backup. So I went to the Notifications configuration to test the notification target with the "Test" button. It asks "Do you want to send a test notification to 'mail-to-admin'?". I click "Yes".

Then I get an error popup saying "Could not test target: could not notify via endpoint(s): mail-to-admin: Invalid input (500)".

Where are the logs for this, so I can debug what "Invalid input (500)" means? This error message is not really helpful. In the journalctl, I did not find anything.

Thanks and best regards
 
Unfortunately, the SMTP library that we use to send mails isn't super cooperative when it comes to log output, at least in its default settings. So right now there is no way to get more information. I'll try to investigate in the future and check if there is a way to make it more verbose ;)

Would you mind sharing your /etc/pve/notifications.cfg? Maybe I can help out this way.
 
Thank you for the quick reply!

Sure, here is the notifications.cfg, I am sure it worked when I first configured it (I think that was before the update to 8.2.7, not sure if something broke there maybe).

EDIT: I also tried deleting and re-creating the smtp notification target, but clicking "Test" still results in the same error.

Proxmox version: 8.2.7

Code:
smtp: mail-to-admin
    author XYZ - Host: $hostname
    from-address admin@xyz.de
    mailto-user root@pam
    mode tls
    port 465
    server smtp.strato.de
    username admin@xyz.de

matcher: default-matcher
    comment Route all notifications to mail-to-admin
    mode all
    target mail-to-admin

sendmail: mail-to-root
    comment Send mails to root@pam's email address
    disable true
    mailto-user root@pam
 
Last edited:
On a hunch, try removing the '$hostname' part from 'author' and see if that changes anything. There is no variable expansion/templating for any config fields, so the mail will appear to be from 'XYZ - Host: $hostname <admin@xyz.de>' . I have not checked if there are any restrictions for the "From" email header, but that's something that you could try out super fast ;)

Hope this helps!
 
That was indeed it. But I did not make that up, I am sure I read somewhere that this is supported... Maybe it was for the backup server and I just copied that over to PVE. Thank you very much.
 
You're welcome! :)

In the UI, the default 'empty text' for the 'From Address' in Sendmail Targets reads something like "Defaults to root@$hostname." Our intent was for this to indicate that by default, mails are sent to 'root' and that Postfix automatically appends the hostname. However, I realize this could also be interpreted as supporting templating or variable expansion. While we may add that feature in the future, it would be helpful to clarify the current behavior in the UI to avoid confusion.
 
You're welcome! :)

In the UI, the default 'empty text' for the 'From Address' in Sendmail Targets reads something like "Defaults to root@$hostname." Our intent was for this to indicate that by default, mails are sent to 'root' and that Postfix automatically appends the hostname. However, I realize this could also be interpreted as supporting templating or variable expansion. While we may add that feature in the future, it would be helpful to clarify the current behavior in the UI to avoid confusion.
I ran into a similar situation with the Author field, but I was not using the '$hostname' variable expansion/templating.

I was trying to use 'Proxmox VE (pve01)' and I received the same error as above. I found deleting the Author field and letting it default resolved the issue.

In further testing, I found that certain characters in the Author field are causing the issue: parentheses, brackets, angle brackets, possibly others; curly braces seem to be fine.

I suspect these characters may be causing issue with interpretation of the from email address. If I recall correctly, these characters have special meaning within an email address.

I found that by putting the Author field contents in quotes (") that all of these characters went through without issue.

Perhaps the contents of the Author field could simply be surrounded by quotes in the code, thus mitigating restriction on these characters.
 
  • Like
Reactions: skyfall
In the OP's case, it was actually the colon ( : ) that was the issue, although as you indicated, there is no expansion so it appears as "author XYZ - Host $hostname".
 
  • Like
Reactions: skyfall