My backup script stopped working after upgrading...

Use this forum if you want to discuss a problem or ask a question related to a hMailServer beta release.
Post Reply
black zero
Normal user
Normal user
Posts: 111
Joined: 2008-08-01 15:26

My backup script stopped working after upgrading...

Post by black zero » 2009-08-29 09:08

to the latest version.

It worked on the older version just fine.

'You do not have access to this property/method. Ensure that hmailserver.application.authenticate() is called with proper login credentials.'

That's the error message. HOWEVER, I didn't change ANYTHING in my script - it's because of the upgrade.

Is there anyway I can do to rectify this situation?

User avatar
martin
Developer
Developer
Posts: 6834
Joined: 2003-11-21 01:09
Location: Sweden
Contact:

Re: My backup script stopped working after upgrading...

Post by martin » 2009-08-29 09:15

It's wrong to assume that a script which works with one version of hMailServer always will work with all future versions. hMailServer evolves and so must scripts sometimes.

So have you done what the error message suggested that you must do?

black zero
Normal user
Normal user
Posts: 111
Joined: 2008-08-01 15:26

Re: My backup script stopped working after upgrading...

Post by black zero » 2009-08-30 06:59

martin wrote:It's wrong to assume that a script which works with one version of hMailServer always will work with all future versions. hMailServer evolves and so must scripts sometimes.

So have you done what the error message suggested that you must do?
Martin, I have no idea what to do. Everything seems ok. My login password is correct, and so is the username. Kindly give me pointer.

User avatar
mattg
Moderator
Moderator
Posts: 21103
Joined: 2007-06-14 05:12
Location: 'The Outback' Australia

Re: My backup script stopped working after upgrading...

Post by mattg » 2009-08-30 10:19

Which version did you upgrade from? Which version did you upgrade to?
What does your Backup script look like?
Just 'cause I link to a page and say little else doesn't mean I am not being nice.
https://www.hmailserver.com/documentation

black zero
Normal user
Normal user
Posts: 111
Joined: 2008-08-01 15:26

Re: My backup script stopped working after upgrading...

Post by black zero » 2009-08-31 03:17

5.1.1 to latest beta.

The script looks as follows

Code: Select all

Option Explicit

const g_sBNFrom = "zero"  'CHANGE ME
const g_sBNFromAddress = "postmasterzero@pt-yyy.co.id"  'CHANGE ME
const g_sAdminPassword = "itsmeadmin"  'CHANGE ME
dim MessageRecipientName, MessageRecipientAddress,MessageRecipientName2, MessageRecipientAddress2, MessageSubject

Sub OnBackupFailed(sReason)
   dim oApp, sBackupLog, oMessage
   Set oApp = CreateObject("hMailServer.Application")
   MessageRecipientName = "mailer"   'CHANGE ME
   MessageRecipientAddress = "xxxx@pt-yyy.co.id"   'CHANGE ME
   MessageRecipientName2 = "yyyy"   'CHANGE ME
   MessageRecipientAddress2 = "yyy@pt-yyy.co.id"
   MessageSubject = "**** Backup FAILED ****"

   ' Give this script permission to access all
   ' hMailServer settings.
   Call oApp.Authenticate("Administrator", g_sAdminPassword)

   sBackupLog = ReadFileUnicode(oApp.Settings.Backup.LogFile)
   DeleteFile(oApp.Settings.Backup.LogFile)

   Set oMessage = CreateObject("hMailServer.Message")
   oMessage.From = g_sBNFrom & " <" & g_sBNFromAddress &  ">"
   oMessage.FromAddress = g_sBNFromAddress
   oMessage.Subject = MessageSubject
   oMessage.AddRecipient MessageRecipientName, MessageRecipientAddress
   'oMessage.AddRecipient MessageRecipientName2, MessageRecipientAddress2
   oMessage.Body = "The backup DID NOT COMPLETE succesfully." & vbNewLine & "PLEASE INVESTIGATE" & vbNewLine & sBackupLog
   oMessage.Save
End Sub

Sub OnBackupCompleted()
   dim oApp, sBackupLog, oMessage
   Set oApp = CreateObject("hMailServer.Application")
   MessageRecipientName = "mailer"  'CHANGE ME
   MessageRecipientAddress = "mailer@pt-yyy.co.id"  'CHANGE ME
   MessageRecipientName2 = "xxxx"   'CHANGE ME
   MessageRecipientAddress2 = "xxxx@pt-yyy.co.id"
   MessageSubject = "Hmailserver Backup Completed"

   ' Give this script permission to access all
   ' hMailServer settings.
   Call oApp.Authenticate("Administrator", g_sAdminPassword)

   sBackupLog = ReadFileUnicode(oApp.Settings.Backup.LogFile)
   DeleteFile(oApp.Settings.Backup.LogFile)

   Set oMessage = CreateObject("hMailServer.Message")
   oMessage.From = g_sBNFrom & " <" & g_sBNFromAddress &  ">"
   oMessage.FromAddress = g_sBNFromAddress
   oMessage.Subject = MessageSubject
   oMessage.AddRecipient MessageRecipientName, MessageRecipientAddress
   'oMessage.AddRecipient MessageRecipientName2, MessageRecipientAddress2
   oMessage.Body = "The backup completed succesfully." & vbNewLine & vbNewLine & "This is an automatic backup notification by postmasterzero..." & vbNewLine  & sBackupLog
   
   oMessage.Save
End Sub

Sub DeleteFile(sFile)
   Dim fso
   Set fso = CreateObject("Scripting.FileSystemObject")
   fso.DeleteFile(sFile)
   Set fso = Nothing
End Sub

Function ReadFileUnicode(sFile)
   dim fso, f
   Set fso = CreateObject("Scripting.FileSystemObject")
   Set f = fso.OpenTextFile(sFile, 1, false, -1)
   ReadFileUnicode = f.ReadAll
   f.Close
   Set f = Nothing
   Set fso = Nothing
End Function

black zero
Normal user
Normal user
Posts: 111
Joined: 2008-08-01 15:26

Re: My backup script stopped working after upgrading...

Post by black zero » 2009-08-31 03:19

- I didn't change any password
- I didn't change any username
- I only upgraded hmail from 5.1.1 to latest beta

User avatar
mattg
Moderator
Moderator
Posts: 21103
Joined: 2007-06-14 05:12
Location: 'The Outback' Australia

Re: My backup script stopped working after upgrading...

Post by mattg » 2009-08-31 03:24

So does the backup still work?
Just not the notification script, is that correct?
Just 'cause I link to a page and say little else doesn't mean I am not being nice.
https://www.hmailserver.com/documentation

black zero
Normal user
Normal user
Posts: 111
Joined: 2008-08-01 15:26

Re: My backup script stopped working after upgrading...

Post by black zero » 2009-08-31 03:35

mattg wrote:So does the backup still work?
Just not the notification script, is that correct?
The backup works if it's done manually via hmail GUI

The script fails at line 20
Call oApp.Authenticate("Administrator", g_sAdminPassword)

I checked the admin password variable and it's correct, and so is the Administrator username as that's what I use to login to hmail.

black zero
Normal user
Normal user
Posts: 111
Joined: 2008-08-01 15:26

Re: My backup script stopped working after upgrading...

Post by black zero » 2009-08-31 03:42

Ok, I just restarted my Windows, reinstall hmail and it works. Weird...

Do we need to restart windows after upgrading HMail?

EDIT: reinstalled it and then restarted windows. My English is bad. >_>

Anyway, problem solved... Thanks everyone.

Post Reply