Notify user when mail arrives

Discussion in 'General' started by muelli75, Nov 4, 2022.

  1. muelli75

    muelli75 Member HowtoForge Supporter

    Hi!

    Is it possible to send an eMail like "You´ve got mail" to a specific user if a mail arrives in a special mailbox?

    I tried to find a solution with Sieve, but it semms that is only possible to forward the mail. But that is not desirable. Only a notification is necessary.

    Until now, we solved this with the Thunderbird plugin "Mail Alert" - but this is no longer actively developed and no longer works with new TB versions.

    Does anyone know advice for this task? TIA
     
  2. nhybgtvfr

    nhybgtvfr Well-Known Member HowtoForge Supporter

    yes, in the mailbox settings in ispconfig, for the mailbox you want someone alerted about, put that persons email address in the 'send copy to' field.
    not only will they get an email about it, it'll include all the original emails contents as well, so they don't even need to login to this special mailbox to see what it's all about. ;)
     
  3. muelli75

    muelli75 Member HowtoForge Supporter

    Thanks for your input!

    But unfortunately, that is exactly what is not desired. The person who is to be notified must not know what is in the mail.

    He should only know that there is a new mail in the mailbox.
     
  4. pyte

    pyte Well-Known Member HowtoForge Supporter

    muelli75, till, ahrasis and 1 other person like this.
  5. muelli75

    muelli75 Member HowtoForge Supporter

    Thank you @pyte - thats exactly what I need!

    Did some tests and it works great. One final question for activating the extentions:

    Its not possible to use the line
    Code:
    require ["enotify", "fileinto", "variables", "envelope"];
    
    in the "Custom Rules"-Section of ispconfig/mail/mail box/specialmailbox, because it has to be defined in the first line of the sieve-file.

    /var/log/mail.log
    Code:
    Nov  5 11:51:29 customermail dovecot: lmtp([email protected])<13341><GWNdFTFAZmMdNAAAEKvxSQ>: Error: sieve: .ispconfig-before: line 15: require commands can only be placed at top level at the beginning of the file
    
    So I found out, thats a good place to insert the needed extenion is /var/vmail/destinationdomain.at/m.mueller/.ispconfig-before.sieve
    But in this .ispconfig-before.sieve-file is the warning
    Code:
    # This sieve script is generated by ISPConfig, any changes made will be overwritten.
    # You can create and activate a per-user sieve script (manually or via managesieve),
    # which will execute after this.
    Where is the best place to bring in my new
    Code:
    require ["fileinto", "mailbox", "regex", "date", "relational", "vacation", "imap4flags", "envelope", "subaddress", "copy", "reject", "enotify", "variables"];
    
    ?

    Thanks for answers?
     
  6. till

    till Super Moderator Staff Member ISPConfig Developer

    Run these commands on your server as root user:

    Code:
    cp -pf /usr/local/ispconfig/server/conf/sieve_filter.master /usr/local/ispconfig/server/conf-custom/sieve_filter.master
    nano /usr/local/ispconfig/server/conf-custom/sieve_filter.master
    Adjust the file as needed and save it.

    Then edit something in the custom filter rules field and save to get the .sieve file of the mailbox created from scratch based on the new master file.
     
    ahrasis and muelli75 like this.
  7. muelli75

    muelli75 Member HowtoForge Supporter

    Thanks Til - nearly what I expected. I expected that I have to use /usr/local/ispconfig/server/conf-custom/mail/
    What about this subdirectory?
     
  8. till

    till Super Moderator Staff Member ISPConfig Developer

    This is for email templates, not filters or config files. Take a look at /usr/local/ispconfig/server/conf/mail/ to see which files are there.
     
    muelli75 likes this.
  9. remkoh

    remkoh Active Member

    @till
    Wouldn't that overwrite all mailboxes when a sync would take place and not just the desired one?

    @muelli75
    If your server has Roundcube installed have you tried the Managesieve plugin?
    That too has an option to send a notification on receiving an email and let's you set different kind of options like notification text and notification sender address for example.
     
  10. muelli75

    muelli75 Member HowtoForge Supporter

    @remkoh - thank you for that hint about Managesieve, I didnt noticed about that. Lets have a look.

    In the meantime I set a custom rule in the email-section of ispconfig.
    Code:
        # :matches is used to get the address from the From header
        if address :matches :all "from" "*" {
            set "from_addr" "${1}";
        }
    
        notify :message "eMail eingetroffen von ${from_addr}"
                        "mailto:[email protected]";
    
    This works like a charm and it do exactly what I want.
     
    till and ahrasis like this.
  11. remkoh

    remkoh Active Member

    Managesieve will create a rule in the background similar to what you've created manually as custom rule.
    So the result will be the same. Difference is it's gui configurable.
     
  12. till

    till Super Moderator Staff Member ISPConfig Developer

    But you should be aware that using managesieve can cause conflicts with ISPConfig and settings you do with managesieve might get removed when you use ISPConfig to set mailbox rules, use autoresponder etc.
     
  13. remkoh

    remkoh Active Member

    My experience is they work side by side. Not sure how it's prioritized though.

    Although I suppose configuring the same thing in two different ways might give you conflicts.
    But that's an user error in my opinion.
     

Share This Page