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 al开发者_如何学Cias 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
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.
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 JohnDoe@example.com -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:
- ls /path/to/plesk/
- mmail.exe --update JohnDoe@example.com -aliases add:JD,JohnD');
精彩评论