skip to Main Content

I have a dedicated server with MediaTemple. I’m searching for an efficient way to create email aliases programmatically in PHP.

The server has Plesk installed so I originally thought I could use the Plesk CLI to create an email alias that piped to a PHP script, but the only method I’ve found with the CLI is to create an email account.

My ideal situation is:

PHP script progammatically creates an email alias that forwards to a PHP script that handles email piping.

What I would like to know is some of the accepted methods of doing this. For instance facebook allows you to create a facebook email account alias that you can use to update your status and post photos by just sending an email to that account.

Thanks

2

Answers


  1. I’ve done this, but not with Plesk.

    You should be able to add aliases to your /etc/aliases file, then you might need to run newaliases as a user with the correct privileges (I’ve done this as root; maybe you could cron it).

    The alias would look something like this:

    aliasname: "|/path/to/mailhandler.php"
    

    mailhandler.php needs to be +x (chmod), and should probably start with #!/usr/bin/env php; from there you can read from the php://stdin stream and parse the headers and/or body to do what you need.

    Login or Signup to reply.
  2. I think you can do it using the Plesk CLI if you read page 163 of the Plesk Command Line Interface document you’ll see this;

    the code would be

    echo exec('> ls /path/to/plesk/ >mail.exe --update [email protected] -aliases  add:JD,JohnD');
    

    you’ll need to make to multipl shell calls on the CLI this will help. http://bytes.com/topic/php/answers/428-executing-multiple-shell-commands-via-one-exec-call

    the two commands you’ll need are:

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search