Menu

Help with command/syntax for email notification

Al Sno
2020-07-29
2022-09-14
  • Al Sno

    Al Sno - 2020-07-29

    I have WCM setup on a local PC, but I'm not skilled at coding to work out the command(s) needed to get an email notification.

    If I want an alert from my Gmail or Yahoo account, do I need to enable anything in my webmail account? What is the specific command that I need to use for the 'Issue command on update'?

    I'd like to run WCM on a home server that is always-on, so I can be notified by email even when my PC is off.

    Thank you all for your help.

     
  • Morten MacFly

    Morten MacFly - 2020-08-18

    I am using mailsend-go on Windows ( https://github.com/muquit/mailsend-go/ ) and have crafted a batch file (WebChangeMonitor_Mail.bat) like this (you'll need to adopt it to your Email server settings):

    @echo off
    set MAIL_CMD="%TOOLS%\mailsend.exe"
    set MAIL_TO_FROM=-to Your.Name@Your.Server -from Your.Name@Your.Server
    set MAIL_SERVER=-ssl -port 465 -auth -smtp Your.SMTP.Server
    set MAIL_LOGIN=-user Your.User.Name -pass "Your.Password"
    set MAIL_SUB_STR=WebChangeMonitor: Item %2 changed.
    set MAIL_SUB=-sub "%MAIL_SUB_STR%"
    set MAIL_MSG_STR=Address: %1, Description: %2, Check: %3, Result: %4, GUID: %5, CRC: %6
    set MAIL_MSG=-M "%MAIL_MSG_STR%"
    set MAIL_ATTACH_FILE=%~dp0pages\%5.new
    set MAIL_ATTACH=-attach "%MAIL_ATTACH_FILE%"
    if not exist "%MAIL_ATTACH_FILE%" set MAIL_ATTACH=
    
    %MAIL_CMD% %MAIL_TO_FROM% %MAIL_SERVER% %MAIL_LOGIN% %MAIL_SUB% %MAIL_MSG% %MAIL_ATTACH%
    

    Then, I setup the command to issue on update in the item settings like this:
    [PATH_TO_WEBMON]\WebChangeMonitor_Mail.bat %addr "%desc" %chk "%res" %guid %crc

    Hope that helps!

     

    Last edit: Morten MacFly 2022-01-30
    • Brian

      Brian - 2022-03-12

      FYI - Not sure if something has changed on mailsend-go but I had to eliminate the hyphen before the "auth" operator and change "-M" to "-msg" for this to work. Thanks for all of this, great program!

       
  • Chris Harris

    Chris Harris - 2022-08-30

    I installed mailsend-go and wrote the above batch file (I needed to change a couple of items and is called mailsend.bat) and the batch file is in my path. If I run the batch file it sends an email with "Address: , Description: , Check: , Result: , GUID: , CRC: " in the message area. I set up a new Tool named Email2 which is "mail.bat %addr "%desc" %chk "%res" %guid %crc". In Alert/log I chose Email2 as default command.

    When I check a web page that has changed a notification comes up saying item is updated but NO email.

    What have I done wrong?

    Thanks
    Chris

     
    • Morten MacFly

      Morten MacFly - 2022-09-03

      "mail.bat %addr "%desc" %chk "%res" %guid %crc"

      Is that true? In that case you should rename the tool to mailsend.bat

      You can also provide the full path to the tool, btw, just to make sure you run the right thing...

      Are there any messages in the log wrt running the tool?

       
  • Anonymous

    Anonymous - 2022-09-09

    Thank you. I had made a mistake. it's now working.

    Can I get the email to show the text differences?

     
    • Anonymous

      Anonymous - 2022-09-10

      You can, but you need an external "Diff-Tool" for that purpose. Usually each Diff-Tool has a command line interface to compare two files and write a report into another file.
      Before you send the email, you can run such a Diff-Tool reporting and attach the report file to the email. You get access to the previous and updated content through the GUID:

      • The old file is: {Your_Temp_Folder_As_Setup_in_WCM}\%GUID%.old
      • The new file is: {Your_Temp_Folder_As_Setup_in_WCM}\%GUID%.new

      The Diff-Command could look like (pseudo notation):
      {Diff-Tool} -left {OLD_FILE} -right {NEW_FILE} -report {REPORT_FILE}
      ...then attach the file to the Email (see command above).

       
  • Chris Harris

    Chris Harris - 2022-09-09

    Thanks. I had made a mistake and now the emails work. I am getting a reply like
    "Address: xxxx.com, Description: xxxx.com, Check: 2022-09-09, Result: 17:51:07, GUID: OK, CRC: D5A19F14-B9B4365E-94453612-B806636F"

    Is there a way that the actual text changes are shown?

    Chris

     
    • Morten MacFly

      Morten MacFly - 2022-09-10

      Sure, you just need to adopt the Email command from above as needed. The message arises from this line:

      set MAIL_MSG_STR=Address: %1, Description: %2, Check: %3, Result: %4, GUID: %5, CRC: %6

      ...you can change that to anything that is more useful to you.

       
  • Chris Harris

    Chris Harris - 2022-09-11

    I was about to try the commands above and now WCM seems to have problems with file locations on startup and when shutting down. I cannot see what I have done. I tried uninstalling and reinstalling the program as well as downgrading to 22.07

    Would you be able to indicate what is wrong and how to fix it?

    Thanks

     

    Last edit: Chris Harris 2022-09-11
  • Anonymous

    Anonymous - 2022-09-14

    You can setup the folder for temporary files under:
    Tools > Configuration -> Files/Folders
    The first item.

    Make sure its not set to "Portable" if the directory you installed WCM into has no write access (which is the case for the standard installation folder under C:\Program files or alike).

     

Anonymous
Anonymous

Add attachments
Cancel





Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.