Koozali.org: home of the SME Server

How do I change a forward address by using a script?

Offline egerards

  • *
  • 11
  • +0/-0
How do I change a forward address by using a script?
« on: October 15, 2008, 11:01:34 AM »
The email for one the accounts on my SME server needs to be forwarded to a weekly changing email address. One of the ways to do this would be to adjust the forward address in the server manager, however preferably I would like to do this via a script that runs on a weekly basis.

Eventually the file ~$USER/.procmailrc needs to be adjusted, but to do it the 'SME way', I suppose the first step would be to make a change in the accounts database:

# db accounts setprop <AccountName> ForwardAddress <email@address.com>

Now I assume the second and last step would be to implement the account database change by calling an SME specific script that will regenerate the .procmailrc file from the account that needs to changed.

Is this the way to go and if so, what would step 2 exactly be?
Regards,

Eric G.

Offline janet

  • *****
  • 4,812
  • +0/-0
Re: How do I change a forward address by using a script?
« Reply #1 on: October 15, 2008, 12:16:56 PM »
egerards

Quote
db accounts setprop <AccountName> ForwardAddress <email@address.com>[/tt]
Now I assume the second and last step would be to implement the account database change by calling an SME specific script that will regenerate the .procmailrc file from the account that needs to changed.
Is this the way to go and if so, what would step 2 exactly be?

db accounts setprop username ForwardAddress emailaddress
followed by
signal-event user-modify username

You can see all the events in
/etc/e-smith/events

If unsure, make the required change to a user in server manager, then examine the messages log file to see what the system does when it automatically makes the change for you. Then duplicate those actions/events in your script.
« Last Edit: October 15, 2008, 12:28:06 PM by mary »
Please search before asking, an answer may already exist.
The Search & other links to useful information are at top of Forum.

Offline cactus

  • *
  • 4,880
  • +3/-0
    • http://www.snetram.nl
Re: How do I change a forward address by using a script?
« Reply #2 on: October 15, 2008, 12:25:55 PM »
The email for one the accounts on my SME server needs to be forwarded to a weekly changing email address. One of the ways to do this would be to adjust the forward address in the server manager, however preferably I would like to do this via a script that runs on a weekly basis.

Eventually the file ~$USER/.procmailrc needs to be adjusted, but to do it the 'SME way', I suppose the first step would be to make a change in the accounts database:

# db accounts setprop <AccountName> ForwardAddress <email@address.com>

Now I assume the second and last step would be to implement the account database change by calling an SME specific script that will regenerate the .procmailrc file from the account that needs to changed.

Is this the way to go and if so, what would step 2 exactly be?
Do not use the brackets, perhaps you need to surround the e-mailaddress with double quotes ("), I guess this should do the trick:
Code: [Select]
db accounts accountname setprop ForwardAddress email@domain.extension
signal-event user-modify accountname
Be careful whose advice you buy, but be patient with those who supply it. Advice is a form of nostalgia, dispensing it is a way of fishing the past from the disposal, wiping it off, painting over the ugly parts and recycling it for more than its worth ~ Baz Luhrmann - Everybody's Free (To Wear Sunscreen)

Offline egerards

  • *
  • 11
  • +0/-0
Re: How do I change a forward address by using a script?
« Reply #3 on: October 15, 2008, 01:26:37 PM »
Quote
Do not use the brackets, perhaps you need to surround the e-mailaddress with double quotes ("), I guess this should do the trick:

The brackets were just there to indicate that a AccountName has to be specified and also an email address. Of course the brackets need to be left out when entering the final command...

Back on topic: 'signal-event usermodify accountname' does the job. There was just one thing I initially forgot when I tried to make this work. I forgot to set EmailForward (visible by 'db accounts getprop accountname EmailForward') from 'local' to 'forward', however when I corrected this it finally worked.

Thanks for the feed back!
Regards,

Eric G.