Script email to API

Use this forum if you have problems with a hMailServer script, such as hMailServer WebAdmin or code in an event handler.
Post Reply
michalhana99
Normal user
Normal user
Posts: 53
Joined: 2017-10-21 12:39

Script email to API

Post by michalhana99 » 2021-09-02 09:29

Hi,
I need help creating a script where incoming email is passed to the API.
This is a transfer to the GSM gateway, which then sends the emails as an SMS.
https://support.yeastar.com/hc/en-us/ar ... _site=true

One e-mail is generated for each telephone number, where "Subject" contains the recipient's telephone number and "Message body" contains the message
I have already solved this problem here viewtopic.php?f=7&t=36291, but using email to SMS.
The problem is that processing via e-mail to SMS takes too long.

Thanks

palinka
Senior user
Senior user
Posts: 2987
Joined: 2017-09-12 17:57

Re: Script email to API

Post by palinka » 2021-09-02 10:15

Have you tried telnet? At least to make contact/logon?

michalhana99
Normal user
Normal user
Posts: 53
Joined: 2017-10-21 12:39

Re: Script email to API

Post by michalhana99 » 2021-09-02 10:27

palinka wrote:
2021-09-02 10:15
Have you tried telnet? At least to make contact/logon?
yes, telnet is fine. the web interface can also be used.
https://support.yeastar.com/hc/en-us/ar ... ce-for-SMS

palinka
Senior user
Senior user
Posts: 2987
Joined: 2017-09-12 17:57

Re: Script email to API

Post by palinka » 2021-09-02 10:39

michalhana99 wrote:
2021-09-02 10:27
palinka wrote:
2021-09-02 10:15
Have you tried telnet? At least to make contact/logon?
yes, telnet is fine. the web interface can also be used.
https://support.yeastar.com/hc/en-us/ar ... ce-for-SMS
Then you should easily be able to send the message using vbs. Sorry i can't help much for the time being. I'm on vacation not far from you. :D I have no access to a computer for another week.

michalhana99
Normal user
Normal user
Posts: 53
Joined: 2017-10-21 12:39

Re: Script email to API

Post by michalhana99 » 2021-09-02 12:15

palinka wrote:
2021-09-02 10:39
michalhana99 wrote:
2021-09-02 10:27
palinka wrote:
2021-09-02 10:15
Have you tried telnet? At least to make contact/logon?
yes, telnet is fine. the web interface can also be used.
https://support.yeastar.com/hc/en-us/ar ... ce-for-SMS
Then you should easily be able to send the message using vbs. Sorry i can't help much for the time being. I'm on vacation not far from you. :D I have no access to a computer for another week.
it could work like this:
const HTTP_HANDLER = "http://[IP]/cgi/WebCGI?1500101=account=[user]&password=[pass]&port=[port]&destination=[phone_number]&content=[MSG]"
but I don't know how I can replace number and message here

palinka
Senior user
Senior user
Posts: 2987
Joined: 2017-09-12 17:57

Re: Script email to API

Post by palinka » 2021-09-02 12:37

michalhana99 wrote:
2021-09-02 12:15
it could work like this:
const HTTP_HANDLER = "http://[IP]/cgi/WebCGI?1500101=account=[user]&password=[pass]&port=[port]&destination=[phone_number]&content=[MSG]"
but I don't know how I can replace number and message here
Do you have a link to documentation for this method? I imagine the message needs to be urlencoded.

michalhana99
Normal user
Normal user
Posts: 53
Joined: 2017-10-21 12:39

Re: Script email to API

Post by michalhana99 » 2021-09-02 13:14

palinka wrote:
2021-09-02 12:37
michalhana99 wrote:
2021-09-02 12:15
it could work like this:
const HTTP_HANDLER = "http://[IP]/cgi/WebCGI?1500101=account=[user]&password=[pass]&port=[port]&destination=[phone_number]&content=[MSG]"
but I don't know how I can replace number and message here
Do you have a link to documentation for this method? I imagine the message needs to be urlencoded.
Unfortunately, I don't have the documentation, I tried it and it probably won't work that way
I have the initial basis of the script from you

Code: Select all

Function oLookup(strRegEx, strMatch, bGlobal)
	If strRegEx = "" Then strRegEx = StrReverse(strMatch)
	With CreateObject("VBScript.RegExp")
		.Pattern = strRegEx
		.Global = bGlobal
		.MultiLine = True
		.IgnoreCase = True
		Set oLookup = .Execute(strMatch)
	End With
End Function

Function RemoveHTML(strHTML)
	With CreateObject("VBScript.RegExp")
		.Pattern = "<[^>]+>|&nbsp;|&lt;|&gt;|&quot;|&amp;"
		.Global = True
		.MultiLine = True
		.IgnoreCase = True
		RemoveHTML = .Replace(strHTML, "")
	End With
End Function

Function Between(sString, sFrom, sTo)
	Dim sTemp
	If InStr(sString, sFrom) > 0 then
		sTemp = Mid(sString, InStr(sString, sFrom) + Len(sFrom))
		If InStr(sTemp, sTo) > 0 then
			Between = Mid(sTemp, 1, InStr(sTemp, sTo) - 1)
		End If
	End If
End Function



Function CloneMail(MobileNumber, SMSMessage)

	Dim SMSRecipientAddress, SMSFromAddress
	Dim strRegEx, Match, Matches
	Dim Latitude, Longitude

	SMSRecipientAddress = "smssend@mhweb.cz"    '<-- account to which message gets forwarded
	SMSFromAddress      = "poplach@mhweb.cz"       '<-- account from which message is sent

	REM - get latitude and longitude - MUST be ahead of removing html tags
	Latitude = Trim(Between(SMSMessage, "GPS:</td><td><b>N ", " E"))
	Longitude = Trim(Between(SMSMessage, " E ", "</b></td></tr>"))


	REM - remove HTML tags
	SMSMessage = RemoveHTML(SMSMessage)
    
    REM - Delete Událost číslo
	strRegEx = "Událost.*"
	Set Matches = oLookup(strRegEx, SMSMessage, False)
	For Each Match In Matches
	   SMSMessage = Replace(SMSMessage, Match.Value, "")
	Next
    
                              
	    REM - replace line breaks with spaces
strRegEx = "(\r\n|\r|\n)"
	Set Matches = oLookup(strRegEx, SMSMessage, False)
	For Each Match In Matches
	   SMSMessage = Replace(SMSMessage, Match.Value, " ")
	Next
	
	REM - replace double/multiple spaces
	strRegEx = "\s{2,}/\s\s+/g"
	Set Matches = oLookup(strRegEx, SMSMessage, False)
	For Each Match In Matches
	   SMSMessage = Replace(SMSMessage, Match.Value, "")
	Next

	REM - replace GPS with google maps link
	strRegEx = "GPS.*(?=\sOBEC)"
	Set Matches = oLookup(strRegEx, SMSMessage, False)
	For Each Match In Matches
	   SMSMessage = Replace(SMSMessage, Match.Value, "http://maps.google.com/maps?q=" & Latitude & "," & Longitude)
	Next                  
    
     REM - Delete okres
	strRegEx = "OKRES.*"
	Set Matches = oLookup(strRegEx, SMSMessage, False)
	For Each Match In Matches
	   SMSMessage = Replace(SMSMessage, Match.Value, "")   
	Next
    
    
     REM - Delete OBEC
	strRegEx = "OBEC."
	Set Matches = oLookup(strRegEx, SMSMessage, False)
	For Each Match In Matches
	   SMSMessage = Replace(SMSMessage, Match.Value, "")   
	Next
    
     REM - Delete ULICE
	strRegEx = "ULICE."
	Set Matches = oLookup(strRegEx, SMSMessage, False)
	For Each Match In Matches
	   SMSMessage = Replace(SMSMessage, Match.Value, "")   
	Next
    
    REM - Delete Adresa Usálosti
	strRegEx = "Adresa události."
	Set Matches = oLookup(strRegEx, SMSMessage, False)
	For Each Match In Matches
	   SMSMessage = Replace(SMSMessage, Match.Value, "")   
	Next          
    
    REM - Repla OZNÁMIL
	strRegEx = "OZNÁMIL."
	Set Matches = oLookup(strRegEx, SMSMessage, False)
	For Each Match In Matches
	   SMSMessage = Replace(SMSMessage, Match.Value, "ozn:")   
	Next  
    
    REM - Repla Telefon
	strRegEx = "Telefon."
	Set Matches = oLookup(strRegEx, SMSMessage, False)
	For Each Match In Matches
	   SMSMessage = Replace(SMSMessage, Match.Value, "Tel:")   
	Next  
    
     REM - Co se stalo
	strRegEx = "Co se stalo."
	Set Matches = oLookup(strRegEx, SMSMessage, False)
	For Each Match In Matches
	   SMSMessage = Replace(SMSMessage, Match.Value, "POZN.:")   
	Next  
     
    
       REM - Repla TECHNICKÁ POMOC
	strRegEx = "TECHNICKÁ POMOC."
	Set Matches = oLookup(strRegEx, SMSMessage, False)
	For Each Match In Matches
	   SMSMessage = Replace(SMSMessage, Match.Value, "TP")   
	Next 
    
    REM - Repla DOPRAVNÍ NEHODA
	strRegEx = "DOPRAVNÍ NEHODA."
	Set Matches = oLookup(strRegEx, SMSMessage, False)
	For Each Match In Matches
	   SMSMessage = Replace(SMSMessage, Match.Value, "DN")   
	Next 
    
    REM - Repla ÚNIK NEBEZPEČNÍCH LÁTEK
	strRegEx = "ÚNIK NEBEZPEČNÍCH LÁTEK."
	Set Matches = oLookup(strRegEx, SMSMessage, False)
	For Each Match In Matches
	   SMSMessage = Replace(SMSMessage, Match.Value, "UNL")   
	Next 
    
    REM - Repla POŽÁR
	strRegEx = "POŽÁR."
	Set Matches = oLookup(strRegEx, SMSMessage, False)
	For Each Match In Matches
	   SMSMessage = Replace(SMSMessage, Match.Value, "P")   
	Next 
    
    REM - Repla ZÁCHRANA OSOB A ZVÍŘAT
	strRegEx = "ZÁCHRANA OSOB A ZVÍŘAT."
	Set Matches = oLookup(strRegEx, SMSMessage, False)
	For Each Match In Matches
	   SMSMessage = Replace(SMSMessage, Match.Value, "ZOZ")   
	Next          
                      
	With CreateObject("hMailServer.Message")
		.From = Chr(34) & SMSFromAddress & Chr(34) & " <" & SMSFromAddress & ">"
		.FromAddress = SMSFromAddress
		.AddRecipient SMSRecipientAddress, SMSRecipientAddress
		.HeaderValue("To") = Chr(34) & SMSRecipientAddress & Chr(34) & " <" & SMSRecipientAddress & ">"
		.Subject = MobileNumber
		.Body = SMSMessage
		.Save
	End With
End Function

Sub SMSAllRecipients(oMessage)
	Dim mobileNumbers, i
	mobileNumbers = Array(720030668)  'All the mobile numbers separated by commas

	For i = 0 To UBound(mobileNumbers)
		Call CloneMail(mobileNumbers(i), oMessage.HTMLBody)
		Wait(5)  'Wait 10 seconds - make sure "Wait" function is in your eventhandlers.vbs
	Next
End Sub

Sub HasiciNovaBystrice(oMessage)
	Dim mobileNumbers, i
	mobileNumbers = Array(720030668,725972971,721024493,606062486,724074434,722582342,721061954,728713356,723945008,601542515,721168563,728888240,720221148,605048860,607811238,734359660,723471878,724076781,723426503,722502735,728187328,721228879,721079001,723549409,722115480,606055943,606542215,721175600,725445677,724204202,775537939,720191551,728498328,722215600,724723484)  'All the mobile numbers separated by commas

	For i = 0 To UBound(mobileNumbers)
		Call CloneMail(mobileNumbers(i), oMessage.HTMLBody)
		Wait(7)  'Wait 10 seconds - make sure "Wait" function is in your eventhandlers.vbs
	Next
End Sub

So I would omit mail cloning. now the question of how to pass information to the specified url, and then run it.

palinka
Senior user
Senior user
Posts: 2987
Joined: 2017-09-12 17:57

Re: Script email to API

Post by palinka » 2021-09-02 13:26

Documentation here: https://support.yeastar.com/hc/en-us/ar ... _site=true

It's a pretty simple function. However i can't do this on my phone.

You have to urlencode the message before sending. I don't think there's a native function in vbs that does that. I'm sure goolag can help there. That's probably why it failed for you when you tried in the browser.

Encode your message using this and try again. https://www.urlencoder.io/

Also, if you use "+" in the phone number, that also must be urlencoded like this: %2B

Ex.: "+12125551234" becomes "%2B12125551234"

michalhana99
Normal user
Normal user
Posts: 53
Joined: 2017-10-21 12:39

Re: Script email to API

Post by michalhana99 » 2021-09-02 13:43

palinka wrote:
2021-09-02 13:26
Documentation here: https://support.yeastar.com/hc/en-us/ar ... _site=true

It's a pretty simple function. However i can't do this on my phone.

You have to urlencode the message before sending. I don't think there's a native function in vbs that does that. I'm sure goolag can help there. That's probably why it failed for you when you tried in the browser.

Encode your message using this and try again. https://www.urlencoder.io/

Also, if you use "+" in the phone number, that also must be urlencoded like this: %2B

Ex.: "+12125551234" becomes "%2B12125551234"
it did not fail when the attempt was in force, but passed without problems.
I used
Sending SMS format:
http://[IP]/cgi/WebCGI?1500101=account=[user]&password=[pass]&port=[port]&destination=[phone_number]&content=[MSG]

The problem occurred after editing the script. The error will be between the chair and the computer :-)

palinka
Senior user
Senior user
Posts: 2987
Joined: 2017-09-12 17:57

Re: Script email to API

Post by palinka » 2021-09-03 09:12

https://www.motobit.com/help/scptutl/sa323.htm

Parking this interesting vbs urlencode function for future use.

michalhana99
Normal user
Normal user
Posts: 53
Joined: 2017-10-21 12:39

Re: Script email to API

Post by michalhana99 » 2021-09-03 10:34

palinka wrote:
2021-09-03 09:12
https://www.motobit.com/help/scptutl/sa323.htm

Parking this interesting vbs urlencode function for future use.

Code: Select all

Function Wait(sec)
   With CreateObject("WScript.Shell")
'     .Run "timeout /T " & Int(sec), 0, True
'     .Run "sleep -m " & Int(sec * 1000), 0, True
      .Run "powershell Start-Sleep -Milliseconds " & Int(sec * 1000), 0, True
   End With
End Function

Function oLookup(strRegEx, strMatch, bGlobal)
	If strRegEx = "" Then strRegEx = StrReverse(strMatch)
	With CreateObject("VBScript.RegExp")
		.Pattern = strRegEx
		.Global = bGlobal
		.MultiLine = True
		.IgnoreCase = True
		Set oLookup = .Execute(strMatch)
	End With
End Function

Function RemoveHTML(strHTML)
	With CreateObject("VBScript.RegExp")
		.Pattern = "<[^>]+>|&nbsp;|&lt;|&gt;|&quot;|&amp;"
		.Global = True
		.MultiLine = True
		.IgnoreCase = True
		RemoveHTML = .Replace(strHTML, "")
	End With
End Function

Function Between(sString, sFrom, sTo)
	Dim sTemp
	If InStr(sString, sFrom) > 0 then
		sTemp = Mid(sString, InStr(sString, sFrom) + Len(sFrom))
		If InStr(sTemp, sTo) > 0 then
			Between = Mid(sTemp, 1, InStr(sTemp, sTo) - 1)
		End If
	End If
End Function



Function CloneMail(MobileNumber, SMSMessage)

	Dim SMSRecipientAddress, SMSFromAddress
	Dim strRegEx, Match, Matches
	Dim Latitude, Longitude
    

	SMSRecipientAddress = "smssend@mhweb.cz"    '<-- account to which message gets forwarded
	SMSFromAddress      = "poplach@mhweb.cz"       '<-- account from which message is sent

	REM - get latitude and longitude - MUST be ahead of removing html tags
	Latitude = Trim(Between(SMSMessage, "GPS:</td><td><b>N ", " E"))
	Longitude = Trim(Between(SMSMessage, " E ", "</b></td></tr>"))


	REM - remove HTML tags
	SMSMessage = RemoveHTML(SMSMessage)
    
    REM - Delete Událost číslo
	strRegEx = "Událost.*"
	Set Matches = oLookup(strRegEx, SMSMessage, False)
	For Each Match In Matches
	   SMSMessage = Replace(SMSMessage, Match.Value, "")
	Next
    
                              
	    REM - replace line breaks with spaces
strRegEx = "(\r\n|\r|\n)"
	Set Matches = oLookup(strRegEx, SMSMessage, False)
	For Each Match In Matches
	   SMSMessage = Replace(SMSMessage, Match.Value, " ")
	Next
	
	REM - replace double/multiple spaces
	strRegEx = "\s{2,}/\s\s+/g"
	Set Matches = oLookup(strRegEx, SMSMessage, False)
	For Each Match In Matches
	   SMSMessage = Replace(SMSMessage, Match.Value, "")
	Next

	REM - replace GPS with google maps link
	strRegEx = "GPS.*(?=\sOBEC)"
	Set Matches = oLookup(strRegEx, SMSMessage, False)
	For Each Match In Matches
	   SMSMessage = Replace(SMSMessage, Match.Value, "http://maps.google.com/maps?q=" & Latitude & "," & Longitude)
	Next                  
    
     REM - Delete okres
	strRegEx = "OKRES.*"
	Set Matches = oLookup(strRegEx, SMSMessage, False)
	For Each Match In Matches
	   SMSMessage = Replace(SMSMessage, Match.Value, "")   
	Next
    
    
     REM - Delete OBEC
	strRegEx = "OBEC."
	Set Matches = oLookup(strRegEx, SMSMessage, False)
	For Each Match In Matches
	   SMSMessage = Replace(SMSMessage, Match.Value, "")   
	Next
    
     REM - Delete ULICE
	strRegEx = "ULICE."
	Set Matches = oLookup(strRegEx, SMSMessage, False)
	For Each Match In Matches
	   SMSMessage = Replace(SMSMessage, Match.Value, "")   
	Next
    
    REM - Delete Adresa Usálosti
	strRegEx = "Adresa události."
	Set Matches = oLookup(strRegEx, SMSMessage, False)
	For Each Match In Matches
	   SMSMessage = Replace(SMSMessage, Match.Value, "")   
	Next          
    
    REM - Repla OZNÁMIL
	strRegEx = "OZNÁMIL."
	Set Matches = oLookup(strRegEx, SMSMessage, False)
	For Each Match In Matches
	   SMSMessage = Replace(SMSMessage, Match.Value, "ozn:")   
	Next  
    
    REM - Repla Telefon
	strRegEx = "Telefon."
	Set Matches = oLookup(strRegEx, SMSMessage, False)
	For Each Match In Matches
	   SMSMessage = Replace(SMSMessage, Match.Value, "Tel:")   
	Next  
    
     REM - Co se stalo
	strRegEx = "Co se stalo."
	Set Matches = oLookup(strRegEx, SMSMessage, False)
	For Each Match In Matches
	   SMSMessage = Replace(SMSMessage, Match.Value, "POZN.:")   
	Next  
     
    
       REM - Repla TECHNICKÁ POMOC
	strRegEx = "TECHNICKÁ POMOC."
	Set Matches = oLookup(strRegEx, SMSMessage, False)
	For Each Match In Matches
	   SMSMessage = Replace(SMSMessage, Match.Value, "TP")   
	Next 
    
    REM - Repla DOPRAVNÍ NEHODA
	strRegEx = "DOPRAVNÍ NEHODA."
	Set Matches = oLookup(strRegEx, SMSMessage, False)
	For Each Match In Matches
	   SMSMessage = Replace(SMSMessage, Match.Value, "DN")   
	Next 
    
    REM - Repla ÚNIK NEBEZPEČNÍCH LÁTEK
	strRegEx = "ÚNIK NEBEZPEČNÍCH LÁTEK."
	Set Matches = oLookup(strRegEx, SMSMessage, False)
	For Each Match In Matches
	   SMSMessage = Replace(SMSMessage, Match.Value, "UNL")   
	Next 
    
    REM - Repla POŽÁR
	strRegEx = "POŽÁR."
	Set Matches = oLookup(strRegEx, SMSMessage, False)
	For Each Match In Matches
	   SMSMessage = Replace(SMSMessage, Match.Value, "P")   
	Next 
    
    REM - Repla ZÁCHRANA OSOB A ZVÍŘAT
	strRegEx = "ZÁCHRANA OSOB A ZVÍŘAT."
	Set Matches = oLookup(strRegEx, SMSMessage, False)
	For Each Match In Matches
	   SMSMessage = Replace(SMSMessage, Match.Value, "ZOZ")   
	Next          
                      


	REM -  set Mobilenumber http
    strRegEx = "destination=."
	Set Matches = oLookup(strRegEx, HTTP_HANDLER, False)
	For Each Match In Matches
    url = Replace(SMSMessage, Match.Value, MobileNumber)
     
     Next
    
     REM -  set Mobilenumber http
    strRegEx = "content=."
	Set Matches = oLookup(strRegEx, HTTP_HANDLER, False)
	For Each Match In Matches
    url = Replace(SMSMessage, Match.Value, SMSMessage) 
    
    With CreateObject("hMailServer.Message")   
    .Subject = MobileNumber
	.Body = SMSMessage
    .url=   "http://10.0.0.31/cgi/WebCGI?1500101=account=apiuser&password=apipass&port=1&destination=SMS_destination&content=SMS_message_encoded"
    End With
    next 
    

	HTTP_HANDLER = url

	 
End Function


Sub SMSAllRecipients(oMessage)
	Dim mobileNumbers, i
	mobileNumbers = Array(720030668)  'All the mobile numbers separated by commas

	For i = 0 To UBound(mobileNumbers)
		Call CloneMail(mobileNumbers(i), oMessage.HTMLBody)
		Wait(5)  'Wait 10 seconds - make sure "Wait" function is in your eventhandlers.vbs
	Next
End Sub


REM - set Mobilenumber http
strRegEx = "destination=."
Set Matches = oLookup(strRegEx, HTTP_HANDLER, False)
For Each Match In Matches
url = Replace(SMSMessage, Match.Value, MobileNumber)

Next

REM - set Mobilenumber http
strRegEx = "content=."
Set Matches = oLookup(strRegEx, HTTP_HANDLER, False)
For Each Match In Matches
url = Replace(SMSMessage, Match.Value, SMSMessage)

With CreateObject("hMailServer.Message")
.Subject = MobileNumber
.Body = SMSMessage
.url= "http://10.0.0.31/cgi/WebCGI?1500101=acc ... ge_encoded"
End With
next


HTTP_HANDLER = url


End Function

the error will be in the highlighted line, can you please advise what am wrong?

Thank you

Could it work like this? I can't handle it :(

palinka
Senior user
Senior user
Posts: 2987
Joined: 2017-09-12 17:57

Re: Script email to API

Post by palinka » 2021-09-03 11:44

I still have no access to a computer and doing this on the phone is absurdly difficult.

First, you need to url encode the message. So you can try adding the function i linked to, then at the bottom of function CloneMail add:

SMSMessage = URLEncode(SMSMessage, UTF-8)

Also get rid of everything you added.

Them get rid of the part about the hmailserver message object. You are not sending an email - you're sending directly to the modem api. Replace that with something like this:

Code: Select all

Set oXML = CreateObject ("Msxml2.XMLHTTP.3.0")
	oXML.Open "GET", "http://10.0.0.31/cgi/WebCGI?1500101=account=apiuser&password=apipass&port=1&destination=" & MobileNumber & "&content=" & SMSMessage, False
	oXML.Send

Make sure to replace the apiuser, apipass and port number with the actual ones.

This should at least get you in the right direction.

michalhana99
Normal user
Normal user
Posts: 53
Joined: 2017-10-21 12:39

Re: Script email to API

Post by michalhana99 » 2021-09-03 18:27

palinka wrote:
2021-09-03 11:44
I still have no access to a computer and doing this on the phone is absurdly difficult.

First, you need to url encode the message. So you can try adding the function i linked to, then at the bottom of function CloneMail add:

SMSMessage = URLEncode(SMSMessage, UTF-8)

Also get rid of everything you added.

Them get rid of the part about the hmailserver message object. You are not sending an email - you're sending directly to the modem api. Replace that with something like this:

Code: Select all

Set oXML = CreateObject ("Msxml2.XMLHTTP.3.0")
	oXML.Open "GET", "http://10.0.0.31/cgi/WebCGI?1500101=account=apiuser&password=apipass&port=1&destination=" & MobileNumber & "&content=" & SMSMessage, False
	oXML.Send

Make sure to replace the apiuser, apipass and port number with the actual ones.

This should at least get you in the right direction.
odzkoušeno a bohužel nefunguje
hmailserver logs

Code: Select all

"Script Error: Source: Microsoft VBScript - chyba p"DEBUG"	12372	"2021-09-03 09:55:48.399"	"Event completed"

Code: Select all

Function Wait(sec)
   With CreateObject("WScript.Shell")
'     .Run "timeout /T " & Int(sec), 0, True
'     .Run "sleep -m " & Int(sec * 1000), 0, True
      .Run "powershell Start-Sleep -Milliseconds " & Int(sec * 1000), 0, True
   End With
End Function


Function URLEncode(ByVal Data, CharSet)
  'Create a ByteArray object
  Dim ByteArray: Set ByteArray = CreateObject("ScriptUtils.ByteArray")
  If Len(CharSet)>0 Then ByteArray.CharSet = CharSet
    
  ByteArray.String = Data

  If ByteArray.Length > 0 Then
    Dim I, C, Out

    For I = 1 To ByteArray.Length
      'For each byte of the encoded data
      C = ByteArray(I)
      If C = 32 Then 'convert space to +
        Out = Out + "+"
      ElseIf (C < 48 Or c>126) Or (c>56 And c<=64) Then
        Out = Out + "%" + Hex(C)
      Else
        Out = Out + Chr(c)
      End If
    Next
    URLEncode = Out
  End If
End Function

Function oLookup(strRegEx, strMatch, bGlobal)
	If strRegEx = "" Then strRegEx = StrReverse(strMatch)
	With CreateObject("VBScript.RegExp")
		.Pattern = strRegEx
		.Global = bGlobal
		.MultiLine = True
		.IgnoreCase = True
		Set oLookup = .Execute(strMatch)
	End With
End Function

Function RemoveHTML(strHTML)
	With CreateObject("VBScript.RegExp")
		.Pattern = "<[^>]+>|&nbsp;|&lt;|&gt;|&quot;|&amp;"
		.Global = True
		.MultiLine = True
		.IgnoreCase = True
		RemoveHTML = .Replace(strHTML, "")
	End With
End Function

Function Between(sString, sFrom, sTo)
	Dim sTemp
	If InStr(sString, sFrom) > 0 then
		sTemp = Mid(sString, InStr(sString, sFrom) + Len(sFrom))
		If InStr(sTemp, sTo) > 0 then
			Between = Mid(sTemp, 1, InStr(sTemp, sTo) - 1)
		End If
	End If
End Function



Function CloneMail(MobileNumber, SMSMessage)

	Dim strRegEx, Match, Matches
	Dim Latitude, Longitude

	
	REM - get latitude and longitude - MUST be ahead of removing html tags
	Latitude = Trim(Between(SMSMessage, "GPS:</td><td><b>N ", " E"))
	Longitude = Trim(Between(SMSMessage, " E ", "</b></td></tr>"))


	REM - remove HTML tags
	SMSMessage = RemoveHTML(SMSMessage)
    
    REM - Delete Událost číslo
	strRegEx = "Událost.*"
	Set Matches = oLookup(strRegEx, SMSMessage, False)
	For Each Match In Matches
	   SMSMessage = Replace(SMSMessage, Match.Value, "")
	Next
    
                              
	    REM - replace line breaks with spaces
strRegEx = "(\r\n|\r|\n)"
	Set Matches = oLookup(strRegEx, SMSMessage, False)
	For Each Match In Matches
	   SMSMessage = Replace(SMSMessage, Match.Value, " ")
	Next
	
	REM - replace double/multiple spaces
	strRegEx = "\s{2,}/\s\s+/g"
	Set Matches = oLookup(strRegEx, SMSMessage, False)
	For Each Match In Matches
	   SMSMessage = Replace(SMSMessage, Match.Value, "")
	Next

	REM - replace GPS with google maps link
	strRegEx = "GPS.*(?=\sOBEC)"
	Set Matches = oLookup(strRegEx, SMSMessage, False)
	For Each Match In Matches
	   SMSMessage = Replace(SMSMessage, Match.Value, "http://maps.google.com/maps?q=" & Latitude & "," & Longitude)
	Next                  
    
     REM - Delete okres
	strRegEx = "OKRES.*"
	Set Matches = oLookup(strRegEx, SMSMessage, False)
	For Each Match In Matches
	   SMSMessage = Replace(SMSMessage, Match.Value, "")   
	Next
    
    
     REM - Delete OBEC
	strRegEx = "OBEC."
	Set Matches = oLookup(strRegEx, SMSMessage, False)
	For Each Match In Matches
	   SMSMessage = Replace(SMSMessage, Match.Value, "")   
	Next
    
     REM - Delete ULICE
	strRegEx = "ULICE."
	Set Matches = oLookup(strRegEx, SMSMessage, False)
	For Each Match In Matches
	   SMSMessage = Replace(SMSMessage, Match.Value, "")   
	Next
    
    REM - Delete Adresa Usálosti
	strRegEx = "Adresa události."
	Set Matches = oLookup(strRegEx, SMSMessage, False)
	For Each Match In Matches
	   SMSMessage = Replace(SMSMessage, Match.Value, "")   
	Next          
    
    REM - Repla OZNÁMIL
	strRegEx = "OZNÁMIL."
	Set Matches = oLookup(strRegEx, SMSMessage, False)
	For Each Match In Matches
	   SMSMessage = Replace(SMSMessage, Match.Value, "ozn:")   
	Next  
    
    REM - Repla Telefon
	strRegEx = "Telefon."
	Set Matches = oLookup(strRegEx, SMSMessage, False)
	For Each Match In Matches
	   SMSMessage = Replace(SMSMessage, Match.Value, "Tel:")   
	Next  
    
     REM - Co se stalo
	strRegEx = "Co se stalo."
	Set Matches = oLookup(strRegEx, SMSMessage, False)
	For Each Match In Matches
	   SMSMessage = Replace(SMSMessage, Match.Value, "POZN.:")   
	Next  
     
    
       REM - Repla TECHNICKÁ POMOC
	strRegEx = "TECHNICKÁ POMOC."
	Set Matches = oLookup(strRegEx, SMSMessage, False)
	For Each Match In Matches
	   SMSMessage = Replace(SMSMessage, Match.Value, "TP")   
	Next 
    
    REM - Repla DOPRAVNÍ NEHODA
	strRegEx = "DOPRAVNÍ NEHODA."
	Set Matches = oLookup(strRegEx, SMSMessage, False)
	For Each Match In Matches
	   SMSMessage = Replace(SMSMessage, Match.Value, "DN")   
	Next 
    
    REM - Repla ÚNIK NEBEZPEČNÍCH LÁTEK
	strRegEx = "ÚNIK NEBEZPEČNÍCH LÁTEK."
	Set Matches = oLookup(strRegEx, SMSMessage, False)
	For Each Match In Matches
	   SMSMessage = Replace(SMSMessage, Match.Value, "UNL")   
	Next 
    
    REM - Repla POŽÁR
	strRegEx = "POŽÁR."
	Set Matches = oLookup(strRegEx, SMSMessage, False)
	For Each Match In Matches
	   SMSMessage = Replace(SMSMessage, Match.Value, "P")   
	Next 
    
    REM - Repla ZÁCHRANA OSOB A ZVÍŘAT
	strRegEx = "ZÁCHRANA OSOB A ZVÍŘAT."
	Set Matches = oLookup(strRegEx, SMSMessage, False)
	For Each Match In Matches
	   SMSMessage = Replace(SMSMessage, Match.Value, "ZOZ") 
         
	Next 
    SMSMessage = URLEncode (SMSMessage, UTF-8)         
               
                      
	With CreateObject ("Msxml2.XMLHTTP.3.0")
    oXML.Open "GET", "http://10.0.0.31/cgi/WebCGI?1500101=account=apiuser&password=apipass&port=1&destination=" & MobileNumber & "&content=" & SMSMessage, False
	oXML.Send  
    End With
End Function

  

Sub SMSAllRecipients(oMessage)
	Dim mobileNumbers, i
	mobileNumbers = Array(720030668)  'All the mobile numbers separated by commas

	For i = 0 To UBound(mobileNumbers)
		Call CloneMail(mobileNumbers(i), oMessage.SMSMessage)
		Wait(5)  'Wait 10 seconds - make sure "Wait" function is in your eventhandlers.vbs
	Next
End Sub

palinka
Senior user
Senior user
Posts: 2987
Joined: 2017-09-12 17:57

Re: Script email to API

Post by palinka » 2021-09-03 21:52

Code: Select all

Dim oXML
Set oXML = CreateObject ("Msxml2.XMLHTTP.3.0")
oXML.Open "GET", "http://10.0.0.31/cgi/WebCGI?1500101=account=apiuser&password=apipass&port=1&destination=" & MobileNumber & "&content=" & SMSMessage, False
oXML.Send
michalhana99 wrote:
2021-09-03 18:27
odzkoušeno a bohužel nefunguje
hmailserver logs

Code: Select all

"Script Error: Source: Microsoft VBScript - chyba p
"DEBUG"	12372	"2021-09-03 09:55:48.399"	"Event completed"
You cut off the error line. What is the full error description?

michalhana99
Normal user
Normal user
Posts: 53
Joined: 2017-10-21 12:39

Re: Script email to API

Post by michalhana99 » 2021-09-05 10:02

palinka wrote:
2021-09-03 21:52

Code: Select all

Dim oXML
Set oXML = CreateObject ("Msxml2.XMLHTTP.3.0")
oXML.Open "GET", "http://10.0.0.31/cgi/WebCGI?1500101=account=apiuser&password=apipass&port=1&destination=" & MobileNumber & "&content=" & SMSMessage, False
oXML.Send
michalhana99 wrote:
2021-09-03 18:27
odzkoušeno a bohužel nefunguje
hmailserver logs

Code: Select all

"Script Error: Source: Microsoft VBScript - chyba p
"DEBUG"	12372	"2021-09-03 09:55:48.399"	"Event completed"
You cut off the error line. What is the full error description?

unfortunately not Dim oXML does not work

Toto je celý chybový kód uložený v hamilserver logs
"ERROR" 6704 "2021-09-05 09:21:48.175" "Script Error: Source: Microsoft VBScript - chyba p"DEBUG" 6704 "2021-09-05 09:21:48.175" "Event completed"

palinka
Senior user
Senior user
Posts: 2987
Joined: 2017-09-12 17:57

Re: Script email to API

Post by palinka » 2021-09-05 10:35

If that is your error log then i think you may have bigger problems. Something is definitely wrong.

michalhana99
Normal user
Normal user
Posts: 53
Joined: 2017-10-21 12:39

Re: Script email to API

Post by michalhana99 » 2021-09-06 08:46

palinka wrote:
2021-09-05 10:35
If that is your error log then i think you may have bigger problems. Something is definitely wrong.

Code: Select all

42440: "DEBUG"	6704	"2021-09-05 09:21:48.159"	"Executing task DeliveryTask in work queue SMTP delivery queue"
42441: "DEBUG"	6704	"2021-09-05 09:21:48.159"	"Delivering message..."
42442: "APPLICATION"	6704	"2021-09-05 09:21:48.175"	"SMTPDeliverer - Message 1645201: Delivering message from test@mhweb.cz to test@mhweb.cz. File: C:\Program Files (x86)\hMailServer\Data\{9C2559E9-FA63-4AE4-8AFA-0D46153E5293}.eml"
42443: "DEBUG"	6704	"2021-09-05 09:21:48.175"	"Applying rules"
42444: "DEBUG"	6704	"2021-09-05 09:21:48.175"	"Applying rule nkcr.cz"
42445: "DEBUG"	6704	"2021-09-05 09:21:48.175"	"Applying rule judrvlckova"
42446: "DEBUG"	6704	"2021-09-05 09:21:48.175"	"Applying rule Spam filter"
42447: "DEBUG"	6704	"2021-09-05 09:21:48.175"	"Applying rule bana.cz_zkopce"
42448: "DEBUG"	6704	"2021-09-05 09:21:48.175"	"Applying rule zakladzdarma.cz_zkopce"
42449: "DEBUG"	6704	"2021-09-05 09:21:48.175"	"Applying rule dinara"
42450: "DEBUG"	6704	"2021-09-05 09:21:48.175"	"Applying rule .com"
42451: "DEBUG"	6704	"2021-09-05 09:21:48.175"	"Performing local delivery"
42452: "DEBUG"	6704	"2021-09-05 09:21:48.175"	"Applying rules"
42453: "DEBUG"	6704	"2021-09-05 09:21:48.175"	"Applying rule CZTEST"
42454: "DEBUG"	6704	"2021-09-05 09:21:48.175"	"Performing rule action"
42455: "DEBUG"	6704	"2021-09-05 09:21:48.175"	"Executing event Unknown"
42456: "ERROR"	6704	"2021-09-05 09:21:48.175"	"Script Error: Source: Microsoft VBScript - chyba p"DEBUG"	6704	"2021-09-05 09:21:48.175"	"Event completed"
42457: "DEBUG"	6704	"2021-09-05 09:21:48.175"	"Saving message: {9C2559E9-FA63-4AE4-8AFA-0D46153E5293}.eml"
42458: "DEBUG"	6704	"2021-09-05 09:21:48.175"	"AWStats::LogDeliverySuccess"
42459: "DEBUG"	6704	"2021-09-05 09:21:48.175"	"Local delivery completed"
42460: "APPLICATION"	6704	"2021-09-05 09:21:48.175"	"SMTPDeliverer - Message 1645201: Message delivery thread completed."

User avatar
jimimaseye
Moderator
Moderator
Posts: 9236
Joined: 2011-09-08 17:48

Re: Script email to API

Post by jimimaseye » 2021-09-06 08:53

michalhana99 wrote:
2021-09-06 08:46
palinka wrote:
2021-09-05 10:35
If that is your error log then i think you may have bigger problems. Something is definitely wrong.

Code: Select all

42455: "DEBUG"	6704	"2021-09-05 09:21:48.175"	"Executing event Unknown"
42456: "ERROR"	6704	"2021-09-05 09:21:48.175"	"Script Error: Source: Microsoft VBScript - chyba p"DEBUG"	6704	"2021-09-05 09:21:48.175"	"Event completed"
42457: "DEBUG"	6704	"2021-09-05 09:21:48.175"	"Saving message: {9C2559E9-FA63-4AE4-8AFA-0D46153E5293}.eml"
42458: "DEBUG"	6704	"2021-09-05 09:21:48.175"	"AWStats::LogDeliverySuccess"
42459: "DEBUG"	6704	"2021-09-05 09:21:48.175"	"Local delivery completed"
42460: "APPLICATION"	6704	"2021-09-05 09:21:48.175"	"SMTPDeliverer - Message 1645201: Message delivery thread completed."
run this and post the results: viewtopic.php?f=20&t=30914 And include rules when prompted. Also post contents of your eventhandlers script (without passwords)

[Entered by mobile. Excuse my spelling.]
5.7 on test.
SpamassassinForWindows 3.4.0 spamd service
AV: Clamwin + Clamd service + sanesecurity defs : https://www.hmailserver.com/forum/viewtopic.php?f=21&t=26829

michalhana99
Normal user
Normal user
Posts: 53
Joined: 2017-10-21 12:39

Re: Script email to API

Post by michalhana99 » 2021-09-06 14:09

jimimaseye wrote:
2021-09-06 08:53
michalhana99 wrote:
2021-09-06 08:46
palinka wrote:
2021-09-05 10:35
If that is your error log then i think you may have bigger problems. Something is definitely wrong.

Code: Select all

42455: "DEBUG"	6704	"2021-09-05 09:21:48.175"	"Executing event Unknown"
42456: "ERROR"	6704	"2021-09-05 09:21:48.175"	"Script Error: Source: Microsoft VBScript - chyba p"DEBUG"	6704	"2021-09-05 09:21:48.175"	"Event completed"
42457: "DEBUG"	6704	"2021-09-05 09:21:48.175"	"Saving message: {9C2559E9-FA63-4AE4-8AFA-0D46153E5293}.eml"
42458: "DEBUG"	6704	"2021-09-05 09:21:48.175"	"AWStats::LogDeliverySuccess"
42459: "DEBUG"	6704	"2021-09-05 09:21:48.175"	"Local delivery completed"
42460: "APPLICATION"	6704	"2021-09-05 09:21:48.175"	"SMTPDeliverer - Message 1645201: Message delivery thread completed."
run this and post the results: viewtopic.php?f=20&t=30914 And include rules when prompted. Also post contents of your eventhandlers script (without passwords)

[Entered by mobile. Excuse my spelling.]
Error LOG

Code: Select all

[code]2021-09-06   Hmailserver: 5.6.8-B2538

DOMAINS

   "Domain1.com" - arxxxxxxx.cz                   Enabled: False

   "Domain2.com" - brxxxxxxxxxxxxxxxxxx.cz        Enabled: True

SIGNATURE         LIMITS                       DKIM               ADVANCED
  Enabled: False   Max size:                0   Enabled: True    
                   Max message size:        0   Header:   Relaxed  Plus addressing: False
                   Max size of accounts:    0   Body:     Relaxed
                                                Algorithm: SHA256  Greylisting:      True
                                                Private key: c:\program files (x86)\hmailserver\dkim key\branickestavitelstvi_cz.txt
                                                Selector:    1601531169.branickestavitelstvi

   "Domain3.com" - buxxxxxxxxx.cz                 Enabled: False

   "Domain4.com" - cexxxxx.cz                     Enabled: True

SIGNATURE         LIMITS                       DKIM               ADVANCED
  Enabled: False   Max size:                0   Enabled: False   
                   Max message size:        0                      Plus addressing: False
                   Max size of accounts:    0                    
                                                                   Greylisting:     False

   "Domain5.com" - coxxxxx.cz                     Enabled: True

SIGNATURE         LIMITS                       DKIM               ADVANCED
  Enabled: False   Max size:                0   Enabled: True      Catchall: trash@Domain5.com
                   Max message size:        0   Header:   Relaxed  Plus addressing: False
                   Max size of accounts:    0   Body:     Relaxed
                                                Algorithm: SHA256  Greylisting:     False
                                                Private key: c:\program files (x86)\hmailserver\dkim key\corleon_cz.txt
                                                Selector:    1457337942.corleon

   "Domain6.com" - coxxxxxxxxxxxx.cz              Enabled: True

SIGNATURE         LIMITS                       DKIM               ADVANCED
  Enabled: False   Max size:                0   Enabled: False     Catchall: trash@EXTERNAL.TLD
                   Max message size:        0                      Plus addressing: False
                   Max size of accounts:    0                    
                                                                   Greylisting:      True

   "Domain7.com" - coxxxxxxxxxxxx.cz              Enabled: True

SIGNATURE         LIMITS                       DKIM               ADVANCED
  Enabled: False   Max size:                0   Enabled: False     Catchall: trash@Domain7.com
                   Max message size:        0                      Plus addressing: False
                   Max size of accounts:    0                    
                                                                   Greylisting:     False

   "Domain8.com" - d-xxxxxx.cz                    Enabled: True

SIGNATURE         LIMITS                       DKIM               ADVANCED
  Enabled: False   Max size:                0   Enabled: True      Catchall: trash@Domain8.com
                   Max message size:        0   Header:   Relaxed  Plus addressing: False
                   Max size of accounts:    0   Body:     Relaxed
                                                Algorithm: SHA256  Greylisting:     False
                                                Private key: c:\program files (x86)\hmailserver\dkim key\d_stavby_cz.txt
                                                Selector:    1493303812.stavby

   "Domain9.com" - haxxxxxxxxxxxxxxxx.cz          Enabled: True

SIGNATURE         LIMITS                       DKIM               ADVANCED
  Enabled: False   Max size:                0   Enabled: True    
                   Max message size:        0   Header:   Relaxed  Plus addressing: False
                   Max size of accounts:    0   Body:     Relaxed
                                                Algorithm: SHA256  Greylisting:      True
                                                Private key: c:\program files (x86)\hmailserver\dkim key\hasicinovabystrice_cz.txt
                                                Selector:    1583603410.hasicinovabystrice

   "Domain10.com" - hoxxxxxxxx.cz                 Enabled: True

SIGNATURE         LIMITS                       DKIM               ADVANCED
  Enabled: False   Max size:                0   Enabled: True      Catchall: trash@Domain10.com
                   Max message size:        0   Header:   Relaxed  Plus addressing: False
                   Max size of accounts:    0   Body:     Relaxed
                                                Algorithm: SHA256  Greylisting:     False
                                                Private key: c:\program files (x86)\hmailserver\dkim key\hoteldania_cz.txt
                                                Selector:    1476781265.hoteldania

   "Domain11.com" - huxxxxxxxxxxxxx.cz            Enabled: True

SIGNATURE         LIMITS                       DKIM               ADVANCED
  Enabled: False   Max size:                0   Enabled: True    
                   Max message size:        0   Header:   Relaxed  Plus addressing: False
                   Max size of accounts:    0   Body:     Relaxed
                                                Algorithm: SHA256  Greylisting:      True
                                                Private key: c:\program files (x86)\hmailserver\dkim key\hubertslavonice_cz.txt
                                                Selector:    1553846129.hubertslavonice

   "Domain12.com" - itxxxxxxxx.cz                 Enabled: False

   "Domain13.com" - juxxxxxxxxx.cz                Enabled: True

SIGNATURE         LIMITS                       DKIM               ADVANCED
  Enabled: False   Max size:                0   Enabled: True      Catchall: evlckova.notar@Domain13.com
                   Max message size:        0   Header:   Relaxed  Plus addressing: False
                   Max size of accounts:    0   Body:     Relaxed
                                                Algorithm: SHA256  Greylisting:     False
                                                Private key: c:\program files (x86)\hmailserver\dkim key\judrvlckova_cz.txt
                                                Selector:    1457017421.judrvlckova

   "Domain14.com" - mhxxx.cz                      Enabled: True

SIGNATURE         LIMITS                       DKIM               ADVANCED
  Enabled: False   Max size:                0   Enabled: True      Catchall: trash@Domain14.com
                   Max message size:        0   Header:   Relaxed  Plus addressing: False
                   Max size of accounts:    0   Body:     Relaxed
                                                Algorithm: SHA256  Greylisting:     False
                                                Private key: c:\program files (x86)\hmailserver\dkim key\mhweb_cz.txt
                                                Selector:    1583601426.mhweb

   "Domain15.com" - pexxxxxxxxxxxxx.cz            Enabled: True

SIGNATURE         LIMITS                       DKIM               ADVANCED
  Enabled: False   Max size:                0   Enabled: True      Catchall: trash@Domain15.com
                   Max message size:        0   Header:   Relaxed  Plus addressing: False
                   Max size of accounts:    0   Body:     Relaxed
                                                Algorithm: SHA256  Greylisting:     False
                                                Private key: c:\program files (x86)\hmailserver\dkim key\pensionsedlecko_cz.txt
                                                Selector:    1458558973.pensionsedlecko

   "Domain16.com" - rixxxxxxx.cz                  Enabled: True

SIGNATURE         LIMITS                       DKIM               ADVANCED
  Enabled: False   Max size:             5000   Enabled: True    
                   Max message size:        0   Header:   Relaxed  Plus addressing: False
                   Max size of accounts:    0   Body:     Relaxed
                                                Algorithm: SHA256  Greylisting:     False
                                                Private key: c:\program files (x86)\hmailserver\dkim key\ridewheel_cz.txt
                                                Selector:    1456341020.ridewheel

   "Domain17.com" - sbxxxxxxx.cz                  Enabled: True

SIGNATURE         LIMITS                       DKIM               ADVANCED
  Enabled: False   Max size:             5000   Enabled: True      Catchall: trash@Domain17.com
                   Max message size:        0   Header:   Relaxed  Plus addressing: False
                   Max size of accounts:    0   Body:     Relaxed
                                                Algorithm: SHA256  Greylisting:      True
                                                Private key: c:\program files (x86)\hmailserver\dkim key\sbsbiogas_cz.txt
                                                Selector:    1571945626.sbsbiogas

   "Domain18.com" - skxxxxxxxxx.cz                Enabled: True

SIGNATURE         LIMITS                       DKIM               ADVANCED
  Enabled: False   Max size:                0   Enabled: True    
                   Max message size:        0   Header:   Relaxed  Plus addressing: False
                   Max size of accounts:    0   Body:     Relaxed
                                                Algorithm: SHA256  Greylisting:      True
                                                Private key: c:\program files (x86)\hmailserver\dkim key\skibystrice_cz.txt
                                                Selector:    1479242839.skibystrice

   "Domain19.com" - skxxxxxxxx.cz                 Enabled: True

SIGNATURE         LIMITS                       DKIM               ADVANCED
  Enabled: False   Max size:                0   Enabled: True    
                   Max message size:        0   Header:   Relaxed  Plus addressing: False
                   Max size of accounts:    0   Body:     Relaxed
                                                Algorithm: SHA256  Greylisting:     False
                                                Private key: c:\program files (x86)\hmailserver\dkim key\skicerinek_cz.txt
                                                Selector:    1567773497.skicerinek

   "Domain20.com" - texxxxxxxxxx.cz               Enabled: True

SIGNATURE         LIMITS                       DKIM               ADVANCED
  Enabled: False   Max size:                0   Enabled: False   
                   Max message size:        0                      Plus addressing: False
                   Max size of accounts:    0                    
                                                                   Greylisting:     False

   "Domain21.com" - trxxxxxxxxxxxxx.cz            Enabled: False

   "Domain22.com" - ubxxxxxxxxxxxxxxxx.cz         Enabled: True

SIGNATURE         LIMITS                       DKIM               ADVANCED
  Enabled: False   Max size:                0   Enabled: False     Catchall: ubrousku@Domain22.com
                   Max message size:        0                      Plus addressing: False
                   Max size of accounts:    0                    
                                                                   Greylisting:      True
-----------------------------------------------------------------------------------------------

GLOBAL RULES
  1, nkcr.cz                      Criteria:  Use OR
             To                        Contains        nkcr.cz
             From                      Contains        nkcr.cz
                                  -----Actions-----
             Stop Rule Processing
 ---------------------------------------------------------------------
  2, judrvlckova                  Criteria:  Use AND
             Subject                   Contains        [SPAM]
             To                        Contains        Domain13.com
                                  -----Actions-----
             Stop Rule Processing
 ---------------------------------------------------------------------
  3, Spam filter                  Criteria:  Use OR
             Subject                   Contains        [SPAM]
                                  -----Actions-----
             Move To Folder                            JUNK
             Stop Rule Processing
 ---------------------------------------------------------------------
  4, bana.cz_zkopce               Criteria:  Use AND
             To                        Contains        zkopcedolu
             From                      Contains        @banan.cz
                                  -----Actions-----
             Move To Folder                            SPAM
             Stop Rule Processing
 ---------------------------------------------------------------------
  5, zakladzdarma.cz_zkopce       Criteria:  Use AND
             From                      Contains        zakladzdarma.cz
             To                        Contains        @zkopcedolu.cz
                                  -----Actions-----
             Move To Folder                            SPAM
             Stop Rule Processing
 ---------------------------------------------------------------------
  6, dinara                       Criteria:  Use AND
             From                      Contains        dinara
                                  -----Actions-----
             Delete
 ---------------------------------------------------------------------
  7, .com                         Criteria:  Use AND
             To                        Equals          hotline@Domain14.com
             From                      Contains        .com
                                  -----Actions-----
             Delete
             Stop Rule Processing
-----------------------------------------------------------------------------------------------

ACCOUNT RULES for test@Domain14.com:

  1, CZTEST                       Criteria:  Use AND
             Subject                   Equals          CZTEST
                                  -----Actions-----
             Run Function                              SMSAllRecipients
-----------------------------------------------------------------------------------------------

IP RANGES

IP: 0.0.0.0 - 255.255.255.255     Priority: 100     Name: Internet

  Allow connections                         Other
     SMTP:   True                              Antispam :   True
     POP3:   True                              Antivirus:   True !! ANTIVIRUS NOT CONFIGURED !!
     IMAP:   True                              SSL/TLS:    False

  Allow Deliveries from                     Require Authentication from
     Local To Local       -  True              Local To Local       - False
     Local To External    -  True              Local To External    - False
     External To Local    -  True              External To Local    - False
     External To External -  True              External To External -  True


IP: 50.227.181.106 - 50.227.181.106     Priority: 25     Name: Centrum WHITELIST

  Allow connections                         Other
     SMTP:  False                              Antispam :   True
     POP3:   True                              Antivirus:   True !! ANTIVIRUS NOT CONFIGURED !!
     IMAP:   True                              SSL/TLS:    False


IP: 127.0.0.1 - 127.0.0.1     Priority: 15     Name: My computer

  Allow connections                         Other
     SMTP:  False                              Antispam :   True
     POP3:   True                              Antivirus:   True !! ANTIVIRUS NOT CONFIGURED !!
     IMAP:   True                              SSL/TLS:    False


   !!  Warning:  DEFAULT DOMAIN is SET  !! - "Domain14.com"
------------------------------------------------------
AUTOBANNED Local Addresses:
    No entries

-----------------------------------------------------------------------------------------------

AUTOBAN
  Autoban Enabled: True       Max invalid logon attempts:      3
                              Minutes Before Reset:           30  (0,50 hours, 0,02 days)
                              Minutes to Autoban:           1440  (24,00 hours, 1,00 days)

There is a total of 297 auto-ban IP ranges.
-----------------------------------------------------------------------------------------------

INCOMING RELAYS
   No entries
-----------------------------------------------------------------------------------------------

MIRRORING         Disabled
-----------------------------------------------------------------------------------------------

PROTOCOLS

SMTP
GENERAL             DELIVERY                  RFC COMPLIANCE            ADVANCED
No. Connections:  0  No Retries:  4 Mins: 15   Plain Text:        False  Bind: 
                     Host: Domain14.com        Empty sender:      False  Batch recipients:    50
Max Msg Size: 25480  Relay:-                   Incorrect endings:  True  Use STARTTLS:     False
                     (none entered)            Disc. on invalid:   True  Delivered-To hdr: False
                                               Max number commands:  50  Loop limit:          50
                                                                         Recipient hosts:   5000
  Routes:
     No routes defined.

POP3
  No. Connections: 0

IMAP
 GENERAL                   PUBLIC FOLDERS                    ADVANCED
  No. Connections:   0      Public folder name: Share         IMAP sort:  True
                                                              IMAP Quota: True
                                                              IMAP Idle:  True
                                                              IMAP ACL:   True
                                                              Delim: "/"
-----------------------------------------------------------------------------------------------

ANTISPAM

GENERAL                              SPAM TESTS              Score   SPAMASSASSIN
  Spam Mark:                  6       Use SPF:            True - 3    Use Spamassassin:    True
  Add X-HmailServer-Spam:     True    Check HELO host:    True - 1    Hostname:       127.0.0.1
  Add X-HmailServer-Reason:   True    Check MX records:   True - 2    Port:                 783
  Add X-HmailServer-Subject:  True    Verify DKIM:        True - 3    Use SA score:        True
              Subject Text: "[SPAM]"
  Spam delete threshold: 8         Maximum message size: 1024

DNSBL ENTRIES:
                  zen.spamhaus.org      Score: 5     Result: 127.0.0.*
                    bl.spamcop.net      Score: 3     Result: 127.0.0.*
              sbl-xbl.spamhaus.org      Score: 3     Result: 127.0.0.*

SURBL ENTRIES:
   No 'enabled' entries

GREYLISTING:
  Greylisting:   True       Defer mins: 30       Days Unused: 1      Days Used: 36
                            Bypass SPF: True     Bypass A/MX: False

Greylist WHITELIST ENTRIES:
   No entries

Greylist DOMAINS enabled:
           Domain2.com
           Domain6.com
           Domain9.com
           Domain11.com
           Domain17.com
           Domain18.com
           Domain22.com

WHITELISTING
              0.0.0.0            to    255.255.255.255              mailing[@t]atcomp[dot]cz
              0.0.0.0            to    255.255.255.255              newsletter[@t]artplanet[dot]cz
-----------------------------------------------------------------------------------------------

ANTIVIRUS:  No application configured.

  Block Attachments: True
               *.cmd             Command file for Windows NT
               *.com             Command
               *.cpl             Windows Control Panel extension
               *.csh             CSH script
               *.exe             Executable file
               *.inf             Setup file
               *.lnk             Windows link file
               *.msi             Windows Installer file
               *.msp             Windows Installer patch
               *.reg             Registration key
               *.scf             Windows Explorer command
               *.scr             Windows Screen saver
-----------------------------------------------------------------------------------------------

SSL CERTIFICATES
   No entries
-----------------------------------------------------------------------------------------------

SSL/TLS
             TLS 1.0 :   True
             TLS 1.1 :   True
             TLS 1.2 :   True
             TLS 1.3 :  False                Verify Remote SSL/TLS Certs:  False
SslCipherList  :

ECDHE-RSA-AES128-GCM-SHA256     - ECDHE-ECDSA-AES128-GCM-SHA256   - ECDHE-RSA-AES256-GCM-SHA384     
ECDHE-ECDSA-AES256-GCM-SHA384   - DHE-RSA-AES128-GCM-SHA256       - DHE-DSS-AES128-GCM-SHA256       
kEDH+AESGCM                     - ECDHE-RSA-AES128-SHA256         - ECDHE-ECDSA-AES128-SHA256       
ECDHE-RSA-AES128-SHA            - ECDHE-ECDSA-AES128-SHA          - ECDHE-RSA-AES256-SHA384         
ECDHE-ECDSA-AES256-SHA384       - ECDHE-RSA-AES256-SHA            - ECDHE-ECDSA-AES256-SHA          
DHE-RSA-AES128-SHA256           - DHE-RSA-AES128-SHA              - DHE-DSS-AES128-SHA256           
DHE-RSA-AES256-SHA256           - DHE-DSS-AES256-SHA              - DHE-RSA-AES256-SHA              
AES128-GCM-SHA256               - AES256-GCM-SHA384               - ECDHE-RSA-RC4-SHA               
ECDHE-ECDSA-RC4-SHA             - AES128                          - AES256                          
RC4-SHA                         - HIGH                            - !aNULL                          
!eNULL                          - !EXPORT                         - !DES                            
!3DES                           - !MD5                            - !PSK;                           
-----------------------------------------------------------------------------------------------

TCPIP PORTS                                         Connection Sec
               0.0.0.0         / 25    / SMTP   -   None                
               0.0.0.0         / 110   / POP3   -   None                
               0.0.0.0         / 143   / IMAP   -   None                
               0.0.0.0         / 587   / SMTP   -   None                
               0.0.0.0         / 993   / IMAP   -   None                
               0.0.0.0         / 993   / IMAP   -   None                
-----------------------------------------------------------------------------------------------

LOGGING      Logging Enabled: True

  Paths:-
    Current:  C:\Program Files (x86)\hMailServer\Logs\hmailserver_2021-09-06.log
    Error:    C:\Program Files (x86)\hMailServer\Logs\ERROR_hmailserver_2021-09-06.log - !! ERRORS PRESENT !!
    Event:    C:\Program Files (x86)\hMailServer\Logs\hmailserver_events.log - Not present
    Awstats:  C:\Program Files (x86)\hMailServer\Logs\hmailserver_awstats.log
                        APPLICATION -    True
                        SMTP        -    True
                        POP3        -    True
                        IMAP        -      .
                        TCPIP       -    True
                        DEBUG       -    True
                        AWSTATS     -    True
-----------------------------------------------------------------------------------------------

SYSTEM TESTS

Database type: MySQL

IPv6 support is available in operating system.

Backup directory C:\Users\Server\Desktop\Nová složka is writable.

Relative message paths are stored in the database for all messages.

-----------------------------------------------------------------------------------------------

HMAILSERVER.INI

[Directories]
Program folder:  C:\Program Files (x86)\hMailServer\
Database folder: 
Data folder:     C:\Program Files (x86)\hMailServer\Data
Log folder:      C:\Program Files (x86)\hMailServer\Logs
Temp folder:     C:\Program Files (x86)\hMailServer\Temp
Event folder:    C:\Program Files (x86)\hMailServer\Events

[Database]
Type=              MYSQL
Username=          hmailserver
PasswordEncryption=1
Port=              3306
Server=            127.0.0.1
Internal=          0
-----------------------------------------------------------------------------------------------

Generated by HMSSettingsDiagnostics v2.01, Hmailserver Forum.
[/code]

Script code

Code: Select all

Function Wait(sec)
   With CreateObject("WScript.Shell")
'     .Run "timeout /T " & Int(sec), 0, True
'     .Run "sleep -m " & Int(sec * 1000), 0, True
      .Run "powershell Start-Sleep -Milliseconds " & Int(sec * 1000), 0, True
   End With
End Function


Function URLEncode(ByVal Data, CharSet)
  'Create a ByteArray object
  Dim ByteArray: Set ByteArray = CreateObject("ScriptUtils.ByteArray")
  If Len(CharSet)>0 Then ByteArray.CharSet = CharSet
    
  ByteArray.String = Data

  If ByteArray.Length > 0 Then
    Dim I, C, Out

    For I = 1 To ByteArray.Length
      'For each byte of the encoded data
      C = ByteArray(I)
      If C = 32 Then 'convert space to +
        Out = Out + "+"
      ElseIf (C < 48 Or c>126) Or (c>56 And c<=64) Then
        Out = Out + "%" + Hex(C)
      Else
        Out = Out + Chr(c)
      End If
    Next
    URLEncode = Out
  End If
End Function

Function oLookup(strRegEx, strMatch, bGlobal)
	If strRegEx = "" Then strRegEx = StrReverse(strMatch)
	With CreateObject("VBScript.RegExp")
		.Pattern = strRegEx
		.Global = bGlobal
		.MultiLine = True
		.IgnoreCase = True
		Set oLookup = .Execute(strMatch)
	End With
End Function

Function RemoveHTML(strHTML)
	With CreateObject("VBScript.RegExp")
		.Pattern = "<[^>]+>|&nbsp;|&lt;|&gt;|&quot;|&amp;"
		.Global = True
		.MultiLine = True
		.IgnoreCase = True
		RemoveHTML = .Replace(strHTML, "")
	End With
End Function

Function Between(sString, sFrom, sTo)
	Dim sTemp
	If InStr(sString, sFrom) > 0 then
		sTemp = Mid(sString, InStr(sString, sFrom) + Len(sFrom))
		If InStr(sTemp, sTo) > 0 then
			Between = Mid(sTemp, 1, InStr(sTemp, sTo) - 1)
		End If
	End If
End Function



Function CloneMail(MobileNumber, SMSMessage)

	Dim strRegEx, Match, Matches
	Dim Latitude, Longitude
    
    

	
	REM - get latitude and longitude - MUST be ahead of removing html tags
	Latitude = Trim(Between(SMSMessage, "GPS:</td><td><b>N ", " E"))
	Longitude = Trim(Between(SMSMessage, " E ", "</b></td></tr>"))


	REM - remove HTML tags
	SMSMessage = RemoveHTML(SMSMessage)
    
    REM - Delete Událost číslo
	strRegEx = "Událost.*"
	Set Matches = oLookup(strRegEx, SMSMessage, False)
	For Each Match In Matches
	   SMSMessage = Replace(SMSMessage, Match.Value, "")
	Next
    
                              
	    REM - replace line breaks with spaces
strRegEx = "(\r\n|\r|\n)"
	Set Matches = oLookup(strRegEx, SMSMessage, False)
	For Each Match In Matches
	   SMSMessage = Replace(SMSMessage, Match.Value, " ")
	Next
	
	REM - replace double/multiple spaces
	strRegEx = "\s{2,}/\s\s+/g"
	Set Matches = oLookup(strRegEx, SMSMessage, False)
	For Each Match In Matches
	   SMSMessage = Replace(SMSMessage, Match.Value, "")
	Next

	REM - replace GPS with google maps link
	strRegEx = "GPS.*(?=\sOBEC)"
	Set Matches = oLookup(strRegEx, SMSMessage, False)
	For Each Match In Matches
	   SMSMessage = Replace(SMSMessage, Match.Value, "http://maps.google.com/maps?q=" & Latitude & "," & Longitude)
	Next                  
    
     REM - Delete okres
	strRegEx = "OKRES.*"
	Set Matches = oLookup(strRegEx, SMSMessage, False)
	For Each Match In Matches
	   SMSMessage = Replace(SMSMessage, Match.Value, "")   
	Next
    
    
     REM - Delete OBEC
	strRegEx = "OBEC."
	Set Matches = oLookup(strRegEx, SMSMessage, False)
	For Each Match In Matches
	   SMSMessage = Replace(SMSMessage, Match.Value, "")   
	Next
    
     REM - Delete ULICE
	strRegEx = "ULICE."
	Set Matches = oLookup(strRegEx, SMSMessage, False)
	For Each Match In Matches
	   SMSMessage = Replace(SMSMessage, Match.Value, "")   
	Next
    
    REM - Delete Adresa Usálosti
	strRegEx = "Adresa události."
	Set Matches = oLookup(strRegEx, SMSMessage, False)
	For Each Match In Matches
	   SMSMessage = Replace(SMSMessage, Match.Value, "")   
	Next          
    
    REM - Repla OZNÁMIL
	strRegEx = "OZNÁMIL."
	Set Matches = oLookup(strRegEx, SMSMessage, False)
	For Each Match In Matches
	   SMSMessage = Replace(SMSMessage, Match.Value, "ozn:")   
	Next  
    
    REM - Repla Telefon
	strRegEx = "Telefon."
	Set Matches = oLookup(strRegEx, SMSMessage, False)
	For Each Match In Matches
	   SMSMessage = Replace(SMSMessage, Match.Value, "Tel:")   
	Next  
    
     REM - Co se stalo
	strRegEx = "Co se stalo."
	Set Matches = oLookup(strRegEx, SMSMessage, False)
	For Each Match In Matches
	   SMSMessage = Replace(SMSMessage, Match.Value, "POZN.:")   
	Next  
     
    
       REM - Repla TECHNICKÁ POMOC
	strRegEx = "TECHNICKÁ POMOC."
	Set Matches = oLookup(strRegEx, SMSMessage, False)
	For Each Match In Matches
	   SMSMessage = Replace(SMSMessage, Match.Value, "TP")   
	Next 
    
    REM - Repla DOPRAVNÍ NEHODA
	strRegEx = "DOPRAVNÍ NEHODA."
	Set Matches = oLookup(strRegEx, SMSMessage, False)
	For Each Match In Matches
	   SMSMessage = Replace(SMSMessage, Match.Value, "DN")   
	Next 
    
    REM - Repla ÚNIK NEBEZPEČNÍCH LÁTEK
	strRegEx = "ÚNIK NEBEZPEČNÍCH LÁTEK."
	Set Matches = oLookup(strRegEx, SMSMessage, False)
	For Each Match In Matches
	   SMSMessage = Replace(SMSMessage, Match.Value, "UNL")   
	Next 
    
    REM - Repla POŽÁR
	strRegEx = "POŽÁR."
	Set Matches = oLookup(strRegEx, SMSMessage, False)
	For Each Match In Matches
	   SMSMessage = Replace(SMSMessage, Match.Value, "P")   
	Next 
    
    REM - Repla ZÁCHRANA OSOB A ZVÍŘAT
	strRegEx = "ZÁCHRANA OSOB A ZVÍŘAT."
	Set Matches = oLookup(strRegEx, SMSMessage, False)
	For Each Match In Matches
	   SMSMessage = Replace(SMSMessage, Match.Value, "ZOZ") 
         
	Next 
    SMSMessage = URLEncode (SMSMessage, UTF-8)         
               
                      
Dim oXML
Set oXML = CreateObject ("Msxml2.XMLHTTP.3.0")
oXML.Open "GET", "http://10.0.0.31/cgi/WebCGI?1500101=account=apiuser&password=apipass&port=1&destination=" & MobileNumber & "&content=" & SMSMessage, False
oXML.Send
End Function

  

Sub SMSAllRecipients(oMessage)
	Dim mobileNumbers, i
	mobileNumbers = Array(720030668)  'All the mobile numbers separated by commas

	For i = 0 To UBound(mobileNumbers)
		Call CloneMail(mobileNumbers(i), oMessage.HTMLBody)
		Wait(5)  'Wait 10 seconds - make sure "Wait" function is in your eventhandlers.vbs
	Next
End Sub
Function Wait(sec)
   With CreateObject("WScript.Shell")
'     .Run "timeout /T " & Int(sec), 0, True
'     .Run "sleep -m " & Int(sec * 1000), 0, True
      .Run "powershell Start-Sleep -Milliseconds " & Int(sec * 1000), 0, True
   End With
End Function


Function URLEncode(ByVal Data, CharSet)
  'Create a ByteArray object
  Dim ByteArray: Set ByteArray = CreateObject("ScriptUtils.ByteArray")
  If Len(CharSet)>0 Then ByteArray.CharSet = CharSet
    
  ByteArray.String = Data

  If ByteArray.Length > 0 Then
    Dim I, C, Out

    For I = 1 To ByteArray.Length
      'For each byte of the encoded data
      C = ByteArray(I)
      If C = 32 Then 'convert space to +
        Out = Out + "+"
      ElseIf (C < 48 Or c>126) Or (c>56 And c<=64) Then
        Out = Out + "%" + Hex(C)
      Else
        Out = Out + Chr(c)
      End If
    Next
    URLEncode = Out
  End If
End Function

Function oLookup(strRegEx, strMatch, bGlobal)
	If strRegEx = "" Then strRegEx = StrReverse(strMatch)
	With CreateObject("VBScript.RegExp")
		.Pattern = strRegEx
		.Global = bGlobal
		.MultiLine = True
		.IgnoreCase = True
		Set oLookup = .Execute(strMatch)
	End With
End Function

Function RemoveHTML(strHTML)
	With CreateObject("VBScript.RegExp")
		.Pattern = "<[^>]+>|&nbsp;|&lt;|&gt;|&quot;|&amp;"
		.Global = True
		.MultiLine = True
		.IgnoreCase = True
		RemoveHTML = .Replace(strHTML, "")
	End With
End Function

Function Between(sString, sFrom, sTo)
	Dim sTemp
	If InStr(sString, sFrom) > 0 then
		sTemp = Mid(sString, InStr(sString, sFrom) + Len(sFrom))
		If InStr(sTemp, sTo) > 0 then
			Between = Mid(sTemp, 1, InStr(sTemp, sTo) - 1)
		End If
	End If
End Function



Function CloneMail(MobileNumber, SMSMessage)

	Dim strRegEx, Match, Matches
	Dim Latitude, Longitude
    
    

	
	REM - get latitude and longitude - MUST be ahead of removing html tags
	Latitude = Trim(Between(SMSMessage, "GPS:</td><td><b>N ", " E"))
	Longitude = Trim(Between(SMSMessage, " E ", "</b></td></tr>"))


	REM - remove HTML tags
	SMSMessage = RemoveHTML(SMSMessage)
    
    REM - Delete Událost číslo
	strRegEx = "Událost.*"
	Set Matches = oLookup(strRegEx, SMSMessage, False)
	For Each Match In Matches
	   SMSMessage = Replace(SMSMessage, Match.Value, "")
	Next
    
                              
	    REM - replace line breaks with spaces
strRegEx = "(\r\n|\r|\n)"
	Set Matches = oLookup(strRegEx, SMSMessage, False)
	For Each Match In Matches
	   SMSMessage = Replace(SMSMessage, Match.Value, " ")
	Next
	
	REM - replace double/multiple spaces
	strRegEx = "\s{2,}/\s\s+/g"
	Set Matches = oLookup(strRegEx, SMSMessage, False)
	For Each Match In Matches
	   SMSMessage = Replace(SMSMessage, Match.Value, "")
	Next

	REM - replace GPS with google maps link
	strRegEx = "GPS.*(?=\sOBEC)"
	Set Matches = oLookup(strRegEx, SMSMessage, False)
	For Each Match In Matches
	   SMSMessage = Replace(SMSMessage, Match.Value, "http://maps.google.com/maps?q=" & Latitude & "," & Longitude)
	Next                  
    
     REM - Delete okres
	strRegEx = "OKRES.*"
	Set Matches = oLookup(strRegEx, SMSMessage, False)
	For Each Match In Matches
	   SMSMessage = Replace(SMSMessage, Match.Value, "")   
	Next
    
    
     REM - Delete OBEC
	strRegEx = "OBEC."
	Set Matches = oLookup(strRegEx, SMSMessage, False)
	For Each Match In Matches
	   SMSMessage = Replace(SMSMessage, Match.Value, "")   
	Next
    
     REM - Delete ULICE
	strRegEx = "ULICE."
	Set Matches = oLookup(strRegEx, SMSMessage, False)
	For Each Match In Matches
	   SMSMessage = Replace(SMSMessage, Match.Value, "")   
	Next
    
    REM - Delete Adresa Usálosti
	strRegEx = "Adresa události."
	Set Matches = oLookup(strRegEx, SMSMessage, False)
	For Each Match In Matches
	   SMSMessage = Replace(SMSMessage, Match.Value, "")   
	Next          
    
    REM - Repla OZNÁMIL
	strRegEx = "OZNÁMIL."
	Set Matches = oLookup(strRegEx, SMSMessage, False)
	For Each Match In Matches
	   SMSMessage = Replace(SMSMessage, Match.Value, "ozn:")   
	Next  
    
    REM - Repla Telefon
	strRegEx = "Telefon."
	Set Matches = oLookup(strRegEx, SMSMessage, False)
	For Each Match In Matches
	   SMSMessage = Replace(SMSMessage, Match.Value, "Tel:")   
	Next  
    
     REM - Co se stalo
	strRegEx = "Co se stalo."
	Set Matches = oLookup(strRegEx, SMSMessage, False)
	For Each Match In Matches
	   SMSMessage = Replace(SMSMessage, Match.Value, "POZN.:")   
	Next  
     
    
       REM - Repla TECHNICKÁ POMOC
	strRegEx = "TECHNICKÁ POMOC."
	Set Matches = oLookup(strRegEx, SMSMessage, False)
	For Each Match In Matches
	   SMSMessage = Replace(SMSMessage, Match.Value, "TP")   
	Next 
    
    REM - Repla DOPRAVNÍ NEHODA
	strRegEx = "DOPRAVNÍ NEHODA."
	Set Matches = oLookup(strRegEx, SMSMessage, False)
	For Each Match In Matches
	   SMSMessage = Replace(SMSMessage, Match.Value, "DN")   
	Next 
    
    REM - Repla ÚNIK NEBEZPEČNÍCH LÁTEK
	strRegEx = "ÚNIK NEBEZPEČNÍCH LÁTEK."
	Set Matches = oLookup(strRegEx, SMSMessage, False)
	For Each Match In Matches
	   SMSMessage = Replace(SMSMessage, Match.Value, "UNL")   
	Next 
    
    REM - Repla POŽÁR
	strRegEx = "POŽÁR."
	Set Matches = oLookup(strRegEx, SMSMessage, False)
	For Each Match In Matches
	   SMSMessage = Replace(SMSMessage, Match.Value, "P")   
	Next 
    
    REM - Repla ZÁCHRANA OSOB A ZVÍŘAT
	strRegEx = "ZÁCHRANA OSOB A ZVÍŘAT."
	Set Matches = oLookup(strRegEx, SMSMessage, False)
	For Each Match In Matches
	   SMSMessage = Replace(SMSMessage, Match.Value, "ZOZ") 
         
	Next 
    SMSMessage = URLEncode (SMSMessage, UTF-8)         
               
                      
Dim oXML
Set oXML = CreateObject ("Msxml2.XMLHTTP.3.0")
oXML.Open "GET", "http://10.0.0.31/cgi/WebCGI?1500101=account=apiuser&password=apipass&port=1&destination=" & MobileNumber & "&content=" & SMSMessage, False
oXML.Send
End Function

  

Sub SMSAllRecipients(oMessage)
	Dim mobileNumbers, i
	mobileNumbers = Array(720030668)  'All the mobile numbers separated by commas

	For i = 0 To UBound(mobileNumbers)
		Call CloneMail(mobileNumbers(i), oMessage.HTMLBody)
		Wait(5)  'Wait 10 seconds - make sure "Wait" function is in your eventhandlers.vbs
	Next
End Sub


User avatar
jimimaseye
Moderator
Moderator
Posts: 9236
Joined: 2011-09-08 17:48

Re: Script email to API

Post by jimimaseye » 2021-09-06 14:14

Your rule does not have any qualifying criteria (to test for running).

Code: Select all

ACCOUNT RULES for test@Domain14.com:

  1, CZTEST                       Criteria:  Use AND
             Subject                   Equals          CZTEST
                                  -----Actions-----
             Run Function                              SMSAllRecipients
Enter some criteria such as

if Message size > 0 then
5.7 on test.
SpamassassinForWindows 3.4.0 spamd service
AV: Clamwin + Clamd service + sanesecurity defs : https://www.hmailserver.com/forum/viewtopic.php?f=21&t=26829

michalhana99
Normal user
Normal user
Posts: 53
Joined: 2017-10-21 12:39

Re: Script email to API

Post by michalhana99 » 2021-09-06 14:54

jimimaseye wrote:
2021-09-06 14:14
Your rule does not have any qualifying criteria (to test for running).

Code: Select all

ACCOUNT RULES for test@Domain14.com:

  1, CZTEST                       Criteria:  Use AND
             Subject                   Equals          CZTEST
                                  -----Actions-----
             Run Function                              SMSAllRecipients
Enter some criteria such as

if Message size > 0 then
Unfortunately, I still don't see the protocol here

Code: Select all

[code]2021-09-06   Hmailserver: 5.6.8-B2538

DOMAINS

   "Domain1.com" - arxxxxxxx.cz                   Enabled: False

   "Domain2.com" - brxxxxxxxxxxxxxxxxxx.cz        Enabled: True

SIGNATURE         LIMITS                       DKIM               ADVANCED
  Enabled: False   Max size:                0   Enabled: True    
                   Max message size:        0   Header:   Relaxed  Plus addressing: False
                   Max size of accounts:    0   Body:     Relaxed
                                                Algorithm: SHA256  Greylisting:      True
                                                Private key: c:\program files (x86)\hmailserver\dkim key\branickestavitelstvi_cz.txt
                                                Selector:    1601531169.branickestavitelstvi

   "Domain3.com" - buxxxxxxxxx.cz                 Enabled: False

   "Domain4.com" - cexxxxx.cz                     Enabled: True

SIGNATURE         LIMITS                       DKIM               ADVANCED
  Enabled: False   Max size:                0   Enabled: False   
                   Max message size:        0                      Plus addressing: False
                   Max size of accounts:    0                    
                                                                   Greylisting:     False

   "Domain5.com" - coxxxxx.cz                     Enabled: True

SIGNATURE         LIMITS                       DKIM               ADVANCED
  Enabled: False   Max size:                0   Enabled: True      Catchall: trash@Domain5.com
                   Max message size:        0   Header:   Relaxed  Plus addressing: False
                   Max size of accounts:    0   Body:     Relaxed
                                                Algorithm: SHA256  Greylisting:     False
                                                Private key: c:\program files (x86)\hmailserver\dkim key\corleon_cz.txt
                                                Selector:    1457337942.corleon

   "Domain6.com" - coxxxxxxxxxxxx.cz              Enabled: True

SIGNATURE         LIMITS                       DKIM               ADVANCED
  Enabled: False   Max size:                0   Enabled: False     Catchall: trash@EXTERNAL.TLD
                   Max message size:        0                      Plus addressing: False
                   Max size of accounts:    0                    
                                                                   Greylisting:      True

   "Domain7.com" - coxxxxxxxxxxxx.cz              Enabled: True

SIGNATURE         LIMITS                       DKIM               ADVANCED
  Enabled: False   Max size:                0   Enabled: False     Catchall: trash@Domain7.com
                   Max message size:        0                      Plus addressing: False
                   Max size of accounts:    0                    
                                                                   Greylisting:     False

   "Domain8.com" - d-xxxxxx.cz                    Enabled: True

SIGNATURE         LIMITS                       DKIM               ADVANCED
  Enabled: False   Max size:                0   Enabled: True      Catchall: trash@Domain8.com
                   Max message size:        0   Header:   Relaxed  Plus addressing: False
                   Max size of accounts:    0   Body:     Relaxed
                                                Algorithm: SHA256  Greylisting:     False
                                                Private key: c:\program files (x86)\hmailserver\dkim key\d_stavby_cz.txt
                                                Selector:    1493303812.stavby

   "Domain9.com" - haxxxxxxxxxxxxxxxx.cz          Enabled: True

SIGNATURE         LIMITS                       DKIM               ADVANCED
  Enabled: False   Max size:                0   Enabled: True    
                   Max message size:        0   Header:   Relaxed  Plus addressing: False
                   Max size of accounts:    0   Body:     Relaxed
                                                Algorithm: SHA256  Greylisting:      True
                                                Private key: c:\program files (x86)\hmailserver\dkim key\hasicinovabystrice_cz.txt
                                                Selector:    1583603410.hasicinovabystrice

   "Domain10.com" - hoxxxxxxxx.cz                 Enabled: True

SIGNATURE         LIMITS                       DKIM               ADVANCED
  Enabled: False   Max size:                0   Enabled: True      Catchall: trash@Domain10.com
                   Max message size:        0   Header:   Relaxed  Plus addressing: False
                   Max size of accounts:    0   Body:     Relaxed
                                                Algorithm: SHA256  Greylisting:     False
                                                Private key: c:\program files (x86)\hmailserver\dkim key\hoteldania_cz.txt
                                                Selector:    1476781265.hoteldania

   "Domain11.com" - huxxxxxxxxxxxxx.cz            Enabled: True

SIGNATURE         LIMITS                       DKIM               ADVANCED
  Enabled: False   Max size:                0   Enabled: True    
                   Max message size:        0   Header:   Relaxed  Plus addressing: False
                   Max size of accounts:    0   Body:     Relaxed
                                                Algorithm: SHA256  Greylisting:      True
                                                Private key: c:\program files (x86)\hmailserver\dkim key\hubertslavonice_cz.txt
                                                Selector:    1553846129.hubertslavonice

   "Domain12.com" - itxxxxxxxx.cz                 Enabled: False

   "Domain13.com" - juxxxxxxxxx.cz                Enabled: True

SIGNATURE         LIMITS                       DKIM               ADVANCED
  Enabled: False   Max size:                0   Enabled: True      Catchall: evlckova.notar@Domain13.com
                   Max message size:        0   Header:   Relaxed  Plus addressing: False
                   Max size of accounts:    0   Body:     Relaxed
                                                Algorithm: SHA256  Greylisting:     False
                                                Private key: c:\program files (x86)\hmailserver\dkim key\judrvlckova_cz.txt
                                                Selector:    1457017421.judrvlckova

   "Domain14.com" - mhxxx.cz                      Enabled: True

SIGNATURE         LIMITS                       DKIM               ADVANCED
  Enabled: False   Max size:                0   Enabled: True      Catchall: trash@Domain14.com
                   Max message size:        0   Header:   Relaxed  Plus addressing: False
                   Max size of accounts:    0   Body:     Relaxed
                                                Algorithm: SHA256  Greylisting:     False
                                                Private key: c:\program files (x86)\hmailserver\dkim key\mhweb_cz.txt
                                                Selector:    1583601426.mhweb

   "Domain15.com" - pexxxxxxxxxxxxx.cz            Enabled: True

SIGNATURE         LIMITS                       DKIM               ADVANCED
  Enabled: False   Max size:                0   Enabled: True      Catchall: trash@Domain15.com
                   Max message size:        0   Header:   Relaxed  Plus addressing: False
                   Max size of accounts:    0   Body:     Relaxed
                                                Algorithm: SHA256  Greylisting:     False
                                                Private key: c:\program files (x86)\hmailserver\dkim key\pensionsedlecko_cz.txt
                                                Selector:    1458558973.pensionsedlecko

   "Domain16.com" - rixxxxxxx.cz                  Enabled: True

SIGNATURE         LIMITS                       DKIM               ADVANCED
  Enabled: False   Max size:             5000   Enabled: True    
                   Max message size:        0   Header:   Relaxed  Plus addressing: False
                   Max size of accounts:    0   Body:     Relaxed
                                                Algorithm: SHA256  Greylisting:     False
                                                Private key: c:\program files (x86)\hmailserver\dkim key\ridewheel_cz.txt
                                                Selector:    1456341020.ridewheel

   "Domain17.com" - sbxxxxxxx.cz                  Enabled: True

SIGNATURE         LIMITS                       DKIM               ADVANCED
  Enabled: False   Max size:             5000   Enabled: True      Catchall: trash@Domain17.com
                   Max message size:        0   Header:   Relaxed  Plus addressing: False
                   Max size of accounts:    0   Body:     Relaxed
                                                Algorithm: SHA256  Greylisting:      True
                                                Private key: c:\program files (x86)\hmailserver\dkim key\sbsbiogas_cz.txt
                                                Selector:    1571945626.sbsbiogas

   "Domain18.com" - skxxxxxxxxx.cz                Enabled: True

SIGNATURE         LIMITS                       DKIM               ADVANCED
  Enabled: False   Max size:                0   Enabled: True    
                   Max message size:        0   Header:   Relaxed  Plus addressing: False
                   Max size of accounts:    0   Body:     Relaxed
                                                Algorithm: SHA256  Greylisting:      True
                                                Private key: c:\program files (x86)\hmailserver\dkim key\skibystrice_cz.txt
                                                Selector:    1479242839.skibystrice

   "Domain19.com" - skxxxxxxxx.cz                 Enabled: True

SIGNATURE         LIMITS                       DKIM               ADVANCED
  Enabled: False   Max size:                0   Enabled: True    
                   Max message size:        0   Header:   Relaxed  Plus addressing: False
                   Max size of accounts:    0   Body:     Relaxed
                                                Algorithm: SHA256  Greylisting:     False
                                                Private key: c:\program files (x86)\hmailserver\dkim key\skicerinek_cz.txt
                                                Selector:    1567773497.skicerinek

   "Domain20.com" - texxxxxxxxxx.cz               Enabled: True

SIGNATURE         LIMITS                       DKIM               ADVANCED
  Enabled: False   Max size:                0   Enabled: False   
                   Max message size:        0                      Plus addressing: False
                   Max size of accounts:    0                    
                                                                   Greylisting:     False

   "Domain21.com" - trxxxxxxxxxxxxx.cz            Enabled: False

   "Domain22.com" - ubxxxxxxxxxxxxxxxx.cz         Enabled: True

SIGNATURE         LIMITS                       DKIM               ADVANCED
  Enabled: False   Max size:                0   Enabled: False     Catchall: ubrousku@Domain22.com
                   Max message size:        0                      Plus addressing: False
                   Max size of accounts:    0                    
                                                                   Greylisting:      True
-----------------------------------------------------------------------------------------------

GLOBAL RULES
  1, nkcr.cz                      Criteria:  Use OR
             To                        Contains        nkcr.cz
             From                      Contains        nkcr.cz
                                  -----Actions-----
             Stop Rule Processing
 ---------------------------------------------------------------------
  2, judrvlckova                  Criteria:  Use AND
             Subject                   Contains        [SPAM]
             To                        Contains        Domain13.com
                                  -----Actions-----
             Stop Rule Processing
 ---------------------------------------------------------------------
  3, Spam filter                  Criteria:  Use OR
             Subject                   Contains        [SPAM]
                                  -----Actions-----
             Move To Folder                            JUNK
             Stop Rule Processing
 ---------------------------------------------------------------------
  4, bana.cz_zkopce               Criteria:  Use AND
             To                        Contains        zkopcedolu
             From                      Contains        @banan.cz
                                  -----Actions-----
             Move To Folder                            SPAM
             Stop Rule Processing
 ---------------------------------------------------------------------
  5, zakladzdarma.cz_zkopce       Criteria:  Use AND
             From                      Contains        zakladzdarma.cz
             To                        Contains        @zkopcedolu.cz
                                  -----Actions-----
             Move To Folder                            SPAM
             Stop Rule Processing
 ---------------------------------------------------------------------
  6, dinara                       Criteria:  Use AND
             From                      Contains        dinara
                                  -----Actions-----
             Delete
 ---------------------------------------------------------------------
  7, .com                         Criteria:  Use AND
             To                        Equals          hotline@Domain14.com
             From                      Contains        .com
                                  -----Actions-----
             Delete
             Stop Rule Processing
-----------------------------------------------------------------------------------------------

ACCOUNT RULES for test@Domain14.com:

  1, CZTEST                       Criteria:  Use AND
             Message Size              Greater Than    0
                                  -----Actions-----
             Run Function                              SMSAllRecipients
-----------------------------------------------------------------------------------------------

IP RANGES

IP: 0.0.0.0 - 255.255.255.255     Priority: 100     Name: Internet

  Allow connections                         Other
     SMTP:   True                              Antispam :   True
     POP3:   True                              Antivirus:   True !! ANTIVIRUS NOT CONFIGURED !!
     IMAP:   True                              SSL/TLS:    False

  Allow Deliveries from                     Require Authentication from
     Local To Local       -  True              Local To Local       - False
     Local To External    -  True              Local To External    - False
     External To Local    -  True              External To Local    - False
     External To External -  True              External To External -  True


IP: 50.227.181.106 - 50.227.181.106     Priority: 25     Name: Centrum WHITELIST

  Allow connections                         Other
     SMTP:  False                              Antispam :   True
     POP3:   True                              Antivirus:   True !! ANTIVIRUS NOT CONFIGURED !!
     IMAP:   True                              SSL/TLS:    False


IP: 127.0.0.1 - 127.0.0.1     Priority: 15     Name: My computer

  Allow connections                         Other
     SMTP:  False                              Antispam :   True
     POP3:   True                              Antivirus:   True !! ANTIVIRUS NOT CONFIGURED !!
     IMAP:   True                              SSL/TLS:    False


   !!  Warning:  DEFAULT DOMAIN is SET  !! - "Domain14.com"
------------------------------------------------------
AUTOBANNED Local Addresses:
    No entries

-----------------------------------------------------------------------------------------------

AUTOBAN
  Autoban Enabled: True       Max invalid logon attempts:      3
                              Minutes Before Reset:           30  (0,50 hours, 0,02 days)
                              Minutes to Autoban:           1440  (24,00 hours, 1,00 days)

There is a total of 303 auto-ban IP ranges.
-----------------------------------------------------------------------------------------------

INCOMING RELAYS
   No entries
-----------------------------------------------------------------------------------------------

MIRRORING         Disabled
-----------------------------------------------------------------------------------------------

PROTOCOLS

SMTP
GENERAL             DELIVERY                  RFC COMPLIANCE            ADVANCED
No. Connections:  0  No Retries:  4 Mins: 15   Plain Text:        False  Bind: 
                     Host: Domain14.com        Empty sender:      False  Batch recipients:    50
Max Msg Size: 25480  Relay:-                   Incorrect endings:  True  Use STARTTLS:     False
                     (none entered)            Disc. on invalid:   True  Delivered-To hdr: False
                                               Max number commands:  50  Loop limit:          50
                                                                         Recipient hosts:   5000
  Routes:
     No routes defined.

POP3
  No. Connections: 0

IMAP
 GENERAL                   PUBLIC FOLDERS                    ADVANCED
  No. Connections:   0      Public folder name: Share         IMAP sort:  True
                                                              IMAP Quota: True
                                                              IMAP Idle:  True
                                                              IMAP ACL:   True
                                                              Delim: "/"
-----------------------------------------------------------------------------------------------

ANTISPAM

GENERAL                              SPAM TESTS              Score   SPAMASSASSIN
  Spam Mark:                  6       Use SPF:            True - 3    Use Spamassassin:    True
  Add X-HmailServer-Spam:     True    Check HELO host:    True - 1    Hostname:       127.0.0.1
  Add X-HmailServer-Reason:   True    Check MX records:   True - 2    Port:                 783
  Add X-HmailServer-Subject:  True    Verify DKIM:        True - 3    Use SA score:        True
              Subject Text: "[SPAM]"
  Spam delete threshold: 8         Maximum message size: 1024

DNSBL ENTRIES:
                  zen.spamhaus.org      Score: 5     Result: 127.0.0.*
                    bl.spamcop.net      Score: 3     Result: 127.0.0.*
              sbl-xbl.spamhaus.org      Score: 3     Result: 127.0.0.*

SURBL ENTRIES:
   No 'enabled' entries

GREYLISTING:
  Greylisting:   True       Defer mins: 30       Days Unused: 1      Days Used: 36
                            Bypass SPF: True     Bypass A/MX: False

Greylist WHITELIST ENTRIES:
   No entries

Greylist DOMAINS enabled:
           Domain2.com
           Domain6.com
           Domain9.com
           Domain11.com
           Domain17.com
           Domain18.com
           Domain22.com

WHITELISTING
              0.0.0.0            to    255.255.255.255              mailing[@t]atcomp[dot]cz
              0.0.0.0            to    255.255.255.255              newsletter[@t]artplanet[dot]cz
-----------------------------------------------------------------------------------------------

ANTIVIRUS:  No application configured.

  Block Attachments: True
               *.cmd             Command file for Windows NT
               *.com             Command
               *.cpl             Windows Control Panel extension
               *.csh             CSH script
               *.exe             Executable file
               *.inf             Setup file
               *.lnk             Windows link file
               *.msi             Windows Installer file
               *.msp             Windows Installer patch
               *.reg             Registration key
               *.scf             Windows Explorer command
               *.scr             Windows Screen saver
-----------------------------------------------------------------------------------------------

SSL CERTIFICATES
   No entries
-----------------------------------------------------------------------------------------------

SSL/TLS
             TLS 1.0 :   True
             TLS 1.1 :   True
             TLS 1.2 :   True
             TLS 1.3 :  False                Verify Remote SSL/TLS Certs:  False
SslCipherList  :

ECDHE-RSA-AES128-GCM-SHA256     - ECDHE-ECDSA-AES128-GCM-SHA256   - ECDHE-RSA-AES256-GCM-SHA384     
ECDHE-ECDSA-AES256-GCM-SHA384   - DHE-RSA-AES128-GCM-SHA256       - DHE-DSS-AES128-GCM-SHA256       
kEDH+AESGCM                     - ECDHE-RSA-AES128-SHA256         - ECDHE-ECDSA-AES128-SHA256       
ECDHE-RSA-AES128-SHA            - ECDHE-ECDSA-AES128-SHA          - ECDHE-RSA-AES256-SHA384         
ECDHE-ECDSA-AES256-SHA384       - ECDHE-RSA-AES256-SHA            - ECDHE-ECDSA-AES256-SHA          
DHE-RSA-AES128-SHA256           - DHE-RSA-AES128-SHA              - DHE-DSS-AES128-SHA256           
DHE-RSA-AES256-SHA256           - DHE-DSS-AES256-SHA              - DHE-RSA-AES256-SHA              
AES128-GCM-SHA256               - AES256-GCM-SHA384               - ECDHE-RSA-RC4-SHA               
ECDHE-ECDSA-RC4-SHA             - AES128                          - AES256                          
RC4-SHA                         - HIGH                            - !aNULL                          
!eNULL                          - !EXPORT                         - !DES                            
!3DES                           - !MD5                            - !PSK;                           
-----------------------------------------------------------------------------------------------

TCPIP PORTS                                         Connection Sec
               0.0.0.0         / 25    / SMTP   -   None                
               0.0.0.0         / 110   / POP3   -   None                
               0.0.0.0         / 143   / IMAP   -   None                
               0.0.0.0         / 587   / SMTP   -   None                
               0.0.0.0         / 993   / IMAP   -   None                
               0.0.0.0         / 993   / IMAP   -   None                
-----------------------------------------------------------------------------------------------

LOGGING      Logging Enabled: True

  Paths:-
    Current:  C:\Program Files (x86)\hMailServer\Logs\hmailserver_2021-09-06.log
    Error:    C:\Program Files (x86)\hMailServer\Logs\ERROR_hmailserver_2021-09-06.log - !! ERRORS PRESENT !!
    Event:    C:\Program Files (x86)\hMailServer\Logs\hmailserver_events.log - Not present
    Awstats:  C:\Program Files (x86)\hMailServer\Logs\hmailserver_awstats.log
                        APPLICATION -    True
                        SMTP        -    True
                        POP3        -    True
                        IMAP        -      .
                        TCPIP       -    True
                        DEBUG       -    True
                        AWSTATS     -    True
-----------------------------------------------------------------------------------------------

SYSTEM TESTS

Database type: MySQL

IPv6 support is available in operating system.

Backup directory C:\Users\Server\Desktop\Nová složka is writable.

Relative message paths are stored in the database for all messages.

-----------------------------------------------------------------------------------------------

HMAILSERVER.INI

[Directories]
Program folder:  C:\Program Files (x86)\hMailServer\
Database folder: 
Data folder:     C:\Program Files (x86)\hMailServer\Data
Log folder:      C:\Program Files (x86)\hMailServer\Logs
Temp folder:     C:\Program Files (x86)\hMailServer\Temp
Event folder:    C:\Program Files (x86)\hMailServer\Events

[Database]
Type=              MYSQL
Username=          hmailserver
PasswordEncryption=1
Port=              3306
Server=            127.0.0.1
Internal=          0
-----------------------------------------------------------------------------------------------

Generated by HMSSettingsDiagnostics v2.01, Hmailserver Forum.
[/code]

michalhana99
Normal user
Normal user
Posts: 53
Joined: 2017-10-21 12:39

Re: Script email to API

Post by michalhana99 » 2021-09-06 16:43

michalhana99 wrote:
2021-09-05 10:02
palinka wrote:
2021-09-03 21:52

Code: Select all

Dim oXML
Set oXML = CreateObject ("Msxml2.XMLHTTP.3.0")
oXML.Open "GET", "http://10.0.0.31/cgi/WebCGI?1500101=account=apiuser&password=apipass&port=1&destination=" & MobileNumber & "&content=" & SMSMessage, False
oXML.Send
michalhana99 wrote:
2021-09-03 18:27
odzkoušeno a bohužel nefunguje
hmailserver logs

Code: Select all

"Script Error: Source: Microsoft VBScript - chyba p
"DEBUG"	12372	"2021-09-03 09:55:48.399"	"Event completed"
You cut off the error line. What is the full error description?

unfortunately not Dim oXML does not work

Toto je celý chybový kód uložený v hamilserver logs
"ERROR" 6704 "2021-09-05 09:21:48.175" "Script Error: Source: Microsoft VBScript - chyba p"DEBUG" 6704 "2021-09-05 09:21:48.175" "Event completed"
so i found a problem.
The problem is that inside the SMSMessage there is a link to the map.
Is there any way to handle this?

palinka
Senior user
Senior user
Posts: 2987
Joined: 2017-09-12 17:57

Re: Script email to API

Post by palinka » 2021-09-06 18:33

Please copy and post everything in this log:

Code: Select all

    Error:    C:\Program Files (x86)\hMailServer\Logs\ERROR_hmailserver_2021-09-06.log - !! ERRORS PRESENT !!

michalhana99
Normal user
Normal user
Posts: 53
Joined: 2017-10-21 12:39

Re: Script email to API

Post by michalhana99 » 2021-09-06 20:55

palinka wrote:
2021-09-06 18:33
Please copy and post everything in this log:

Code: Select all

    Error:    C:\Program Files (x86)\hMailServer\Logs\ERROR_hmailserver_2021-09-06.log - !! ERRORS PRESENT !!
So the problem is diacritics.
If I send for example: "Ahoj jak se mas" the message arrives without problems
But if I send: "Ahoj jak se máš" the message is not delivered.

The error log is now empty

michalhana99
Normal user
Normal user
Posts: 53
Joined: 2017-10-21 12:39

Re: Script email to API

Post by michalhana99 » 2021-09-07 11:38

palinka wrote:
2021-09-06 18:33
Please copy and post everything in this log:

Code: Select all

    Error:    C:\Program Files (x86)\hMailServer\Logs\ERROR_hmailserver_2021-09-06.log - !! ERRORS PRESENT !!
So I went back to the beginning.
The problem is URLEncode
I've pasted the script you selected, and it just doesn't work.
https://www.motobit.com/help/scptutl/sa323.htm

If I run it without URLEncode, it works fine
however, the message must not contain accents

michalhana99
Normal user
Normal user
Posts: 53
Joined: 2017-10-21 12:39

Re: Script email to API

Post by michalhana99 » 2021-09-07 13:59

michalhana99 wrote:
2021-09-07 11:38
palinka wrote:
2021-09-06 18:33
Please copy and post everything in this log:

Code: Select all

    Error:    C:\Program Files (x86)\hMailServer\Logs\ERROR_hmailserver_2021-09-06.log - !! ERRORS PRESENT !!
So I went back to the beginning.
The problem is URLEncode
I've pasted the script you selected, and it just doesn't work.
https://www.motobit.com/help/scptutl/sa323.htm

If I run it without URLEncode, it works fine
however, the message must not contain accents
Problem solved

Code: Select all

Dim JSEngine
Set JSEngine = CreateObject("MSScriptControl.ScriptControl")
    JSEngine.Language = "JScript"

Function UrlEncode(s)
    UrlEncode = JSEngine.CodeObject.encodeURIComponent(s)
    UrlEncode = Replace(UrlEncode, "'", "%27")
    UrlEncode = Replace(UrlEncode, """", "%22")
End Function
Thanks

michalhana99
Normal user
Normal user
Posts: 53
Joined: 2017-10-21 12:39

Re: Script email to API

Post by michalhana99 » 2021-09-07 17:39

I have one more question
I would also need a script with where the subject will be the phone number and the content of the email will be the content of the SMS, which will then be sent to the API

Code: Select all

Sub APISMS(MobileNumber, SMSMessage)

	.Subject = MobileNumber
	.Body = SMSMessage  
     SMSMessage = UrlEncode(SMSMessage)  
             
Dim oXML
Set oXML = CreateObject ("Msxml2.XMLHTTP.3.0")
oXML.Open "GET", "http://10.0.0.31/cgi/WebCGI?1500101=account=apiuser&password=apipass&port=1&destination=" & MobileNumber & "&content=" & SMSMessage
oXML.Send   
End Sub

palinka
Senior user
Senior user
Posts: 2987
Joined: 2017-09-12 17:57

Re: Script email to API

Post by palinka » 2021-09-11 01:48

michalhana99 wrote:
2021-09-07 17:39
I have one more question
I would also need a script with where the subject will be the phone number and the content of the email will be the content of the SMS, which will then be sent to the API

Code: Select all

Sub APISMS(MobileNumber, SMSMessage)

	.Subject = MobileNumber
	.Body = SMSMessage  
     SMSMessage = UrlEncode(SMSMessage)  
             
Dim oXML
Set oXML = CreateObject ("Msxml2.XMLHTTP.3.0")
oXML.Open "GET", "http://10.0.0.31/cgi/WebCGI?1500101=account=apiuser&password=apipass&port=1&destination=" & MobileNumber & "&content=" & SMSMessage
oXML.Send   
End Sub
Try this - call from rule:

Code: Select all

Sub SMSSingleRecipient(oMessage)
	Dim mobileNumber : mobileNumber = Trim(oMessage.Subject)
	Call CloneMail(mobileNumber, oMessage.HTMLBody)
End Sub
The entire thing would be like this - includes a url encoding function that works with utf-8:

Code: Select all

Function Wait(sec)
   With CreateObject("WScript.Shell")
      .Run "powershell Start-Sleep -Seconds " & Int(sec), 0, True
   End With
End Function

Function oLookup(strRegEx, strMatch, bGlobal)
	If strRegEx = "" Then strRegEx = StrReverse(strMatch)
	With CreateObject("VBScript.RegExp")
		.Pattern = strRegEx
		.Global = bGlobal
		.MultiLine = True
		.IgnoreCase = True
		Set oLookup = .Execute(strMatch)
	End With
End Function

Function RemoveHTML(strHTML)
	With CreateObject("VBScript.RegExp")
		.Pattern = "<[^>]+>|&nbsp;|&lt;|&gt;|&quot;|&amp;"
		.Global = True
		.MultiLine = True
		.IgnoreCase = True
		RemoveHTML = .Replace(strHTML, "")
	End With
End Function

Function Between(sString, sFrom, sTo)
	Dim sTemp
	If InStr(sString, sFrom) > 0 then
		sTemp = Mid(sString, InStr(sString, sFrom) + Len(sFrom))
		If InStr(sTemp, sTo) > 0 then
			Between = Mid(sTemp, 1, InStr(sTemp, sTo) - 1)
		End If
	End If
End Function

Function URLEncode(ByVal str) 'https://dwarf1711.blogspot.com/2007/10/vbscript-urlencode-function.html
	Dim strTemp, strChar
	Dim intPos, intASCII
	strTemp = ""
	strChar = ""
	For intPos = 1 To Len(str)
		intASCII = Asc(Mid(str, intPos, 1))
		If intASCII = 32 Then
			strTemp = strTemp & "+"
		ElseIf ((intASCII < 123) And (intASCII > 96)) Then
			strTemp = strTemp & Chr(intASCII)
		ElseIf ((intASCII < 91) And (intASCII > 64)) Then
			strTemp = strTemp & Chr(intASCII)
		ElseIf ((intASCII < 58) And (intASCII > 47)) Then
			strTemp = strTemp & Chr(intASCII)
		Else
			strChar = Trim(Hex(intASCII))
			If intASCII < 16 Then
				strTemp = strTemp & "%0" & strChar
			Else
				strTemp = strTemp & "%" & strChar
			End If
		End If
	Next
	URLEncode = strTemp
End Function

Function CloneMail(MobileNumber, SMSMessage)

	Dim strRegEx, Match, Matches
	Dim Latitude, Longitude

	REM - get latitude and longitude - MUST be ahead of removing html tags
	Latitude = Trim(Between(SMSMessage, "GPS:</td><td><b>N ", " E"))
	Longitude = Trim(Between(SMSMessage, " E ", "</b></td></tr>"))

	REM - remove HTML tags
	SMSMessage = RemoveHTML(SMSMessage)
    
    REM - Delete Událost číslo
	strRegEx = "Událost.*"
	Set Matches = oLookup(strRegEx, SMSMessage, False)
	For Each Match In Matches
	   SMSMessage = Replace(SMSMessage, Match.Value, "")
	Next
    
    REM - replace line breaks with spaces
	strRegEx = "(\r\n|\r|\n)"
	Set Matches = oLookup(strRegEx, SMSMessage, False)
	For Each Match In Matches
	   SMSMessage = Replace(SMSMessage, Match.Value, " ")
	Next
	
	REM - replace double/multiple spaces
	strRegEx = "\s{2,}/\s\s+/g"
	Set Matches = oLookup(strRegEx, SMSMessage, False)
	For Each Match In Matches
	   SMSMessage = Replace(SMSMessage, Match.Value, "")
	Next

	REM - replace GPS with google maps link
	strRegEx = "GPS.*(?=\sOBEC)"
	Set Matches = oLookup(strRegEx, SMSMessage, False)
	For Each Match In Matches
	   SMSMessage = Replace(SMSMessage, Match.Value, "http://maps.google.com/maps?q=" & Latitude & "," & Longitude)
	Next                  
    
     REM - Delete okres
	strRegEx = "OKRES.*"
	Set Matches = oLookup(strRegEx, SMSMessage, False)
	For Each Match In Matches
	   SMSMessage = Replace(SMSMessage, Match.Value, "")   
	Next
    
	REM - Delete OBEC
	strRegEx = "OBEC."
	Set Matches = oLookup(strRegEx, SMSMessage, False)
	For Each Match In Matches
	   SMSMessage = Replace(SMSMessage, Match.Value, "")   
	Next
    
	REM - Delete ULICE
	strRegEx = "ULICE."
	Set Matches = oLookup(strRegEx, SMSMessage, False)
	For Each Match In Matches
	   SMSMessage = Replace(SMSMessage, Match.Value, "")   
	Next
    
    REM - Delete Adresa Usálosti
	strRegEx = "Adresa události."
	Set Matches = oLookup(strRegEx, SMSMessage, False)
	For Each Match In Matches
	   SMSMessage = Replace(SMSMessage, Match.Value, "")   
	Next          
    
    REM - Repla OZNÁMIL
	strRegEx = "OZNÁMIL."
	Set Matches = oLookup(strRegEx, SMSMessage, False)
	For Each Match In Matches
	   SMSMessage = Replace(SMSMessage, Match.Value, "ozn:")   
	Next  
    
    REM - Repla Telefon
	strRegEx = "Telefon."
	Set Matches = oLookup(strRegEx, SMSMessage, False)
	For Each Match In Matches
	   SMSMessage = Replace(SMSMessage, Match.Value, "Tel:")   
	Next  
    
     REM - Co se stalo
	strRegEx = "Co se stalo."
	Set Matches = oLookup(strRegEx, SMSMessage, False)
	For Each Match In Matches
	   SMSMessage = Replace(SMSMessage, Match.Value, "POZN.:")   
	Next  

	REM - Repla TECHNICKÁ POMOC
	strRegEx = "TECHNICKÁ POMOC."
	Set Matches = oLookup(strRegEx, SMSMessage, False)
	For Each Match In Matches
	   SMSMessage = Replace(SMSMessage, Match.Value, "TP")   
	Next 
    
    REM - Repla DOPRAVNÍ NEHODA
	strRegEx = "DOPRAVNÍ NEHODA."
	Set Matches = oLookup(strRegEx, SMSMessage, False)
	For Each Match In Matches
	   SMSMessage = Replace(SMSMessage, Match.Value, "DN")   
	Next 
    
    REM - Repla ÚNIK NEBEZPEČNÍCH LÁTEK
	strRegEx = "ÚNIK NEBEZPEČNÍCH LÁTEK."
	Set Matches = oLookup(strRegEx, SMSMessage, False)
	For Each Match In Matches
	   SMSMessage = Replace(SMSMessage, Match.Value, "UNL")   
	Next 
    
    REM - Repla POŽÁR
	strRegEx = "POŽÁR."
	Set Matches = oLookup(strRegEx, SMSMessage, False)
	For Each Match In Matches
	   SMSMessage = Replace(SMSMessage, Match.Value, "P")   
	Next 
    
    REM - Repla ZÁCHRANA OSOB A ZVÍŘAT
	strRegEx = "ZÁCHRANA OSOB A ZVÍŘAT."
	Set Matches = oLookup(strRegEx, SMSMessage, False)
	For Each Match In Matches
	   SMSMessage = Replace(SMSMessage, Match.Value, "ZOZ") 
	Next 

	REM - URL Encode message
    SMSMessage = URLEncode(SMSMessage)
	
	REM - Send msg to API
	Dim oXML : Set oXML = CreateObject ("Msxml2.XMLHTTP.3.0")
	oXML.Open "GET", "http://10.0.0.31/cgi/WebCGI?1500101=account=apiuser&password=apipass&port=1&destination=" & MobileNumber & "&content=" & SMSMessage, False
	oXML.Send

End Function

Sub SMSAllRecipients(oMessage)
	Dim mobileNumbers, i
	mobileNumbers = Array(720030668)  'All the mobile numbers separated by commas

	For i = 0 To UBound(mobileNumbers)
		Call CloneMail(mobileNumbers(i), oMessage.HTMLBody)
		Wait(5)  'Wait N seconds between messages
	Next
End Sub

Sub SMSSingleRecipient(oMessage)
	Dim mobileNumber : mobileNumber = Trim(oMessage.Subject)
	Call CloneMail(mobileNumber, oMessage.HTMLBody)
End Sub

michalhana99
Normal user
Normal user
Posts: 53
Joined: 2017-10-21 12:39

Re: Script email to API

Post by michalhana99 » 2021-09-17 09:16

palinka wrote:
2021-09-11 01:48
michalhana99 wrote:
2021-09-07 17:39
I have one more question
I would also need a script with where the subject will be the phone number and the content of the email will be the content of the SMS, which will then be sent to the API

Code: Select all

Sub SMSSingleRecipient(oMessage)
	Dim mobileNumber : mobileNumber = Trim(oMessage.Subject)
	Call CloneMail(mobileNumber, oMessage.HTMLBody)
End Sub
Thanks
but for some reason it loops.
SMS are sent repeatedly.

palinka
Senior user
Senior user
Posts: 2987
Joined: 2017-09-12 17:57

Re: Script email to API

Post by palinka » 2021-09-17 12:02

Please post the rule to call the function.

michalhana99
Normal user
Normal user
Posts: 53
Joined: 2017-10-21 12:39

Re: Script email to API

Post by michalhana99 » 2021-09-17 13:37

palinka wrote:
2021-09-17 12:02
Please post the rule to call the function.
Attachments
Rules.png

palinka
Senior user
Senior user
Posts: 2987
Joined: 2017-09-12 17:57

Re: Script email to API

Post by palinka » 2021-09-17 15:00

michalhana99 wrote:
2021-09-17 13:37
palinka wrote:
2021-09-17 12:02
Please post the rule to call the function.
What is the function you're calling?

I looked at the code again and I don't see where it could be looping.

Does it loop forever or just a few times?

michalhana99
Normal user
Normal user
Posts: 53
Joined: 2017-10-21 12:39

Re: Script email to API

Post by michalhana99 » 2021-09-20 11:59

palinka wrote:
2021-09-17 15:00
michalhana99 wrote:
2021-09-17 13:37
palinka wrote:
2021-09-17 12:02
Please post the rule to call the function.
What is the function you're calling?

I looked at the code again and I don't see where it could be looping.

Does it loop forever or just a few times?
Does it loop forever.
as if the CloneMail function had been called repeatedly

Post Reply