Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Specific profiles (seemingly) not applied #86

Open
pge opened this issue Feb 6, 2024 · 3 comments
Open

Specific profiles (seemingly) not applied #86

pge opened this issue Feb 6, 2024 · 3 comments

Comments

@pge
Copy link

pge commented Feb 6, 2024

First of all: Thanks for all the work!

We have a config that has a defined default profile for mail, mattermost and filters.
Then there is another specific profile that just defines a deviant filter set to filter for another "to" address.

Mail to [email protected] is received and posted to #targetchannelA,
however mail to [email protected] is just shown as

mail2most | time="2024-02-06T07:22:50Z" level=debug msg="processing message" subject="Testmail" uid=18
mail2most | time="2024-02-06T07:22:50Z" level=debug msg="InlineHeader type is" type="text/plain; charset=UTF-8; format=flowed"
mail2most | time="2024-02-06T07:22:50Z" level=debug msg="message not passing the filter" subject="Testmail" uid=18
mail2most | time="2024-02-06T07:22:50Z" level=debug msg=mailserver server="mail.server:993" status=connected
mail2most | time="2024-02-06T07:22:50Z" level=debug msg="checking folders" folders="[INBOX]"

Even though there is no subject filter set at all.

Please see the config attached:

[General]
  # File contains the default file location where mail2most stores its data
  File = "data.json"
  # RunAsService true:
  # check regularly using TimeInterval for new emails
  # false:
  # just check once when u start - requires to restart mail2most for checking again
  RunAsService = true 
  # global time interval for checking mails in seconds
  TimeInterval = 10 

[Logging]
  # Loglevel = ["info", "debug", "error"]
  Loglevel = "debug"
  # LogType = ["json", "text"]
  LogType = "text"
  # Output = ["stdout", "logfile"]
  Output = "stdout"
  # Logfile is used if Output is set to "logfile"
  Logfile = "mail2most.log"

# The DefaultProfile defines a set of defaults used in Profiles that do not define the specific section
# if you create an empty Profile the DefaultProfile is used
# if a Profile contains the section Mail, Mattermost or Filter this section will overwrite the sections from the Default Profile
# at least an empty Profile has to be created for the DefaultProfile to be processed
# only defining the DefaultProfile without having a [Profile] defined will not work
[DefaultProfile]
  # The DefaultProfile.Mail defines a default mailserver
  # if your Profile hast no defined mailserver this information will be used
  [DefaultProfile.Mail]
    ImapServer = "mail.server:993"
    Username = "[email protected]"
    Password = "supersecretpw"
    # ReadOnly does not change any flags on emails
    # Mail2Most saves the information about already send emails on its own
    ReadOnly = false
    # ImapTLS allows you to enable / disable tls encryption whithin the imap protocol (disable when using STARTLS)
    ImapTLS = true
    # StartTLS allows you to enable / disable tls encryption whithin the imap protocol using STARTTLS
    StartTLS = true
    # VerifyTLS disables certificate validation (only disable for self-signed certs)
    VerifyTLS = true
    # Limit allows you to limit the amount of emails read from the mail server, if set to 0 its unlimited
    Limit = 0
    # GenerateLocalUIDs creates a uid from message data instead of fetching the uid from the server 
    # this can be helpfull when getting Invalid messageset errors since some DoveCot mailserver did not implement IMAP correctly
    GenerateLocalUIDs = false

  # The DefaultProfile.Mattermost defines a default mattermost server
  # if your Profile has no defined mattermost server this information will be used
  [DefaultProfile.Mattermost]
    URL = "https://mattermost.server"
    Team = "my-team"
    # you can define username password 
    Username = "m2m-mattermost-user"
    Password = "extremelysecretpass"
    # or accesstoken
        # Channels contains all channels to post your messages 
    # if no channel is defined nothing is posted into a channel
    Channels = ["#targetchannelA"]
    # Users contains all users to post your message to, you can use the username or email address 
    # if no users are defined nothing is posted to any user
    Users = ["user1","user2"]
    # SubjectOnly will post only the mail subject
    SubjectOnly = false
    # BodyOnly will post only the mail body
    BodyOnly = false
    # SkipEmptyMessages - only post messages with non empty email bodys
    SkipEmptyMessages = false
    # StripHTML will remove all HTML tags bevor sending a msg to mattermost
    StripHTML = true
    # ConvertToMarkdown will convert html mails to markdown for better readability in mattermost
    # if this option is set to true the StripHTML option is ignored
    ConvertToMarkdown = true
    # HideFrom allows you to hide the From Address in mattermost messages
    HideFrom = false
    # HideFromEmail true will only display the username
    HideFromEmail = false
    # allow posting mail attachments into mattermost
    MailAttachments = true
    # BodyPrefix adds a prefix to the message body e.g:
    # BodyPrefix = "**This content was forwarded by Mail2Most and might be reformatted**" 
    BodyPrefix = ""
    # BodySuffix adds a suffix to the message body e.g:
    # BodySuffix = "**Disclaimer: This content was forwarded by Mail2Most and might be reformatted**"
    BodySuffix = ""

  # The DefaultProfile.Filter defines a default filter
  # if your Profile has no defined filter this information will be used
  [DefaultProfile.Filter]
    # Folders filters your mails only in specific email folders
    Folders = ["INBOX"]
    # Unseen lets you process unseen mails only by checking the unseen mail flag
    Unseen = true
    # From filters for defined from addresses
    From = [""]
    # To filters for defined to addresses
    To  = ["[email protected]"]
    # Subject filters if the email subject contains one of the defined strings
    #Subject = [""]
    # TimeRange will only process mails that are not older than the defined time range
    TimeRange = "24h"
    # IgnoreMailErrorNotifications sets if Delivery Status Notifications are ignored or not
    IgnoreMailErrorNotifications = true



### Profile targetchannelB
#
#[[Profile]] defines a profile, you can have as many as you want
[[Profile]]
  # IgnoreDefaults lets you ignore the DefaultProfile settings and forces to set everything in the Profile
  # this option should only be used if you try to overwrite a default with an empty value
  # the better way is to define the value only in the profile and not in the defaults
IgnoreDefaults = false

[Profile.Mail]
 
[Profile.Mattermost]
  Channels = ["#targetchannelB"]


  #[Profile.Filter] contains all filters that are applied to your mails and overwrites the default
  [Profile.Filter]
  # Folders filters your mails only in specific email folders
  Folders = ["INBOX"]
  # Unseen lets you process unseen mails only by checking the unseen mail flag
  Unseen = true
  # From filters for defined from addresses
  #From = [""]
  # To filters for defined to addresses
  To  = ["[email protected]"]
  # Subject filters if the email subject contains one of the defined strings
  #Subject = [""]
  # TimeRange will only process mails that are not older than the defined time range
  TimeRange = "24h"
  # EmailErrorNotifications sets if Delivery Status Notifications are ignored or not
  IgnoreMailErrorNotifications = true

We have also tried redefining complete Mail and Mattermost sections for the targetmailB Profile section, with no luck.
Is this even the right way to do it, if only the filters differ from the default profile and mail/mattermost stay the same?

Thanks in advance!

@c-seeger
Copy link
Contributor

c-seeger commented Feb 6, 2024

can you try to set connection information only in the default profile and create 2 profiles one for targetchannelA and one for targetchannelB and see if it works?

As far as i see everything in your inbox with to addres [email protected] should be send to targetchannelB.

also the indentation of Profile.Filter seems a bit off, not sure if thats an issue.

@pge
Copy link
Author

pge commented Feb 6, 2024

This is the updated config.
We now recieve mail for targetmailA, but B still gives and error.

mail2most  | time="2024-02-06T08:51:14Z" level=debug msg="searching unseen" unseen=true
mail2most  | time="2024-02-06T08:51:14Z" level=info msg="unseen mails" ids="[23]"
mail2most  | time="2024-02-06T08:51:14Z" level=debug msg="processing message" subject="Mail an targetmailB" uid=23
mail2most  | time="2024-02-06T08:51:14Z" level=debug msg="InlineHeader type is" type="text/plain; charset=UTF-8; format=flowed"
mail2most  | time="2024-02-06T08:51:14Z" level=debug msg="message not passing the filter" subject="Mail an targetmailB" uid=23
mail2most  | time="2024-02-06T08:51:14Z" level=debug msg=mailserver server="mail.server:993" status=connected
mail2most  | time="2024-02-06T08:51:14Z" level=debug msg="checking folders" folders="[INBOX]"
mail2most  | time="2024-02-06T08:51:14Z" level=info msg="processing mails" folder=INBOX
[DefaultProfile]
  [DefaultProfile.Mail]
    ImapServer = "mail.server:993"
    Username = "[email protected]"
    Password = "supersecretpw"
    ReadOnly = false
    ImapTLS = true
    StartTLS = true
    VerifyTLS = true
    Limit = 0
    GenerateLocalUIDs = false

  [DefaultProfile.Mattermost]
    URL = "https://mattermost.server"
    Team = "my-team""
    Username = "m2m-mattermost-user"
    Password = "extremelysecretpass"
    #AccessToken = "mytoken"
    SubjectOnly = false
    BodyOnly = false
    SkipEmptyMessages = false
    StripHTML = true
    ConvertToMarkdown = true
    HideFrom = false
    HideFromEmail = false
    MailAttachments = true
    BodyPrefix = ""
    BodySuffix = ""

  # The DefaultProfile.Filter defines a default filter
  # if your Profile has no defined filter this information will be used
  [DefaultProfile.Filter]
    # Folders filters your mails only in specific email folders
    Folders = ["INBOX"]
    # Unseen lets you process unseen mails only by checking the unseen mail flag
    Unseen = true
    # From filters for defined from addresses
    From = [""]
    # To filters for defined to addresses
    #To  = [""]
    # Subject filters if the email subject contains one of the defined strings
    #Subject = [""]
    # TimeRange will only process mails that are not older than the defined time range
    TimeRange = "24h"
    # IgnoreMailErrorNotifications sets if Delivery Status Notifications are ignored or not
    IgnoreMailErrorNotifications = true


### Profile [email protected]
[[Profile]]
  IgnoreDefaults = false

  [Profile.Mail]

  [Profile.Mattermost]
  Channels = ["#targetchannelA"]

  [Profile.Filter]
  Folders = ["INBOX"]
  Unseen = true
  To  = ["[email protected]"]
  TimeRange = "24h"
  IgnoreMailErrorNotifications = true


### Profile [email protected]
#
[[Profile]]
  IgnoreDefaults = false
 
  [Profile.Mail]

  [Profile.Mattermost]
  Channels = ["#targetchannelB"]

  [Profile.Filter]
  Folders = ["INBOX"]
  Unseen = true
  #From = [""]
  To  = ["[email protected]"]
  #Subject = [""]
  TimeRange = "24h"
  IgnoreMailErrorNotifications = true

@c-seeger
Copy link
Contributor

c-seeger commented Feb 6, 2024

message not passing the filter" subject="Mail an targetmailB" uid=23 looks like it does not pass the filter, is it older than 24h?, can you outcomment From since its set to empty From = [""]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants