Question

Im trying to make something similar to twitpic.com's email submission feature.

Their address schema is something like username.key@twitpic.com. When you send an email to that address it processes it and uploads your picture.

What im wondering is how they generate and handle those addresses in php. I know how to pipe a single email address to a program using cpanel, but how is this done dynamically?

Ill settle on what this is even called or some google search results so i can do my own research, but i just want a place to start.

Was it helpful?

Solution

There's an option in cpanel to set a default address that catches all email sent to addresses that don't exist. This is probably the easiest way to do it.

In fact, in the version of cpanel I have, if you go to Default Address, and go to Advanced Options there an option to pipe to a program all mail without a valid address.

OTHER TIPS

Ok i found this.
http://twiki.cpanel.net/twiki/bin/view/AllDocumentation/AutomationIntegration/Api2AddForwarder
Trying to find out how/where i can do this using PHP

update
Found a cpanel api class here
http://www.phpclasses.org/browse/file/17045.html
Im trying to contact the author of the class to see how to add the functionality of the api to that class (which can already handle creation of forwarders)

Juse copy and pase below code and replace the desired variables and it will be work :

/*Host Credentials*/
$host = "Host Name";
$port = "Port Number ex. 2083";
$HostUserName = "Your cpanel username";
$HostPassword = "Your cpanel password";
/*-------------------------*/

/*Email details which you want to create*/
$email = "email name which you want to create";
$domain = "Domain name on which you want to create the email for subdomain you can write ex. subdomain.domain.com";
$password = "Password for your email"
$quota = "limit which you want to assign for this account."
/*--------------------*/

$query = 'https://'.$host.':'.$port.'/frontend/x3/mail/doaddpop.html?email='.$email.'&domain='.$domain.'&password='.$password.'&quota='.$quota;
$curl = curl_init();                                 // Create Curl Object
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);       // Allow self-signed certs
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);       // Allow certs that do not match the hostname
curl_setopt($curl, CURLOPT_HEADER, 0);               // Do not include header in output
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);       // Return contents of transfer on curl_exec
$header[0] ="Authorization: Basic " . base64_encode($HostUserName.":".$HostPassword) . "\n\r";
curl_setopt($curl, CURLOPT_HTTPHEADER, $header);     // set the username and password
curl_setopt($curl, CURLOPT_URL, $query);             // execute the query
$result = curl_exec($curl);
curl_close($curl);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top