Sendmail Alias in PHP-scripts
Hello,
I want to make a PHP-script that makes, edits and deletes mail-aliasses on the fly.
My server is Linux with Ensim (using Sendmail). Within Ensim I can of course do these things, but I want a regular PHP-script to manage aliasses.
I have my own Linux + Apache server with root access, but want to solve the problem within my regular PHP scripts.
Thanks
Jeex
Sendmail Alias in PHP-scripts
Moderator: General Moderators
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
Re: Sendmail Alias in PHP-scripts
Are you referring to the files under /etc/aliases ?jeex wrote:Sendmail Alias in PHP-scripts
Hello,
I want to make a PHP-script that makes, edits and deletes mail-aliasses on the fly.
My server is Linux with Ensim (using Sendmail). Within Ensim I can of course do these things, but I want a regular PHP-script to manage aliasses.
I have my own Linux + Apache server with root access, but want to solve the problem within my regular PHP scripts.
Thanks
Jeex
You'll need to set your permissions on the file to be writable by the web user and that could be dangerous but in any case these are very basic colon separated files so it should be easy with a combination of file(), fopen() and fwrite().
Something like:
Code: Select all
function addAlias($alias, $user)
{
`echo "$alias : $user" >> /etc/aliases`; //This is easy peasy
}
function delAlias($alias)
{
$tmp = array();
$lines = file('/etc/aliases');
foreach ($lines as $l)
{
if (!preg_match('/^'.$alias.' :/', $l)) $tmp[] = $l;
}
$data = implode('', $tmp);
$handle = fopen('/etc/aliases', 'w+');
fwrite($handle, $data);
fclose($handle);
}Not possible
If the rights were World-writable, it still wouldn't work because user /root must execute newaliases for every change made.
Maybe virtual hosting is the answer
gr
Jeex
Maybe virtual hosting is the answer
gr
Jeex
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
Re: Not possible
Maybe exim is the answerjeex wrote:If the rights were World-writable, it still wouldn't work because user /root must execute newaliases for every change made.
Maybe virtual hosting is the answer
gr
Jeex
I use exim to serve multiple domains from one server, all with aliases. I have the files secured however but there's no reasn you couldn't make them web writable. No need to reload the server for things like domain additions or alias additions