Possible to create e-mail addresses through pages?


#1

I would like to offer my members a free fowarding address; the problem being is the fact that I’d rather not go through and had add the however many thousands of members who would want one.

Is there a way to create an e-mail either through shell (I could always use shell_exec()), or any other workaround method?

I tried using cURL to do it manually, but I’m unable to log in because it won’t send the login cookie unless you have cookies enabled (Which cURL does not.)

Thanks


#2

Works for me using cURL with PHP.

:cool: Perl / MySQL / HTML+CSS


#3

Any chance you could post the curl command, being careful to strip out your personal info? I would like to integrate the creation of email users into my site admin section. I know how to look at the panel form and sort it all out, but would much rather not duplicate your work, if you’re willing to share.


#4

You just take an example of a POST request and set 4 options:
CURLOPT_SSL_VERIFYHOST
CURLOPT_SSL_VERIFYPEER
CURLOPT_COOKIEFILE
CURLOPT_COOKIEJAR

Don’t forget to call realpath() on the filename.

:cool: Perl / MySQL / HTML+CSS


#5

Hmm, still having no luck getting it working.

I have both CURLOPT_COOKIEFILE and CURLOPT_COOKIEJAR set correctly, using the full path. The cookies are written correctly it seems.

I have SSL_VERIFYHOST set to TRUE and SSL_VERIFYPEER set to 1.

These are the following options set for my POST:

[quote]curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_COOKIEFILE, “/fullpath/here/cookies.txt”);
curl_setopt($ch, CURLOPT_COOKIEJAR, “/fullpath/here/cookies.txt”);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, TRUE);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_URL, $page);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);[/quote]
I’m basically posting to the page with the following data:

And it seems to work, but it says I need to enable cookies and doesn’t login.

I’ve tried a GET request to the Admin panel with those cookies, but it just returns me to the login screen.


#6

It works for me. Have you made sure the cookie file exists and is being written too?
The cookie has to already be in the file in order to login.

[code] $url = ‘https://panel.dreamhost.com/index.cgi’;
$user_agent = ‘Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.1) Gecko/20060111 Firefox/1.5.0.1’;
$post_fields = ‘Nscmd=Nlogin&username=&password=’;
$cookie_file = ‘/home/username/path/filename’;
$cookie_file = realpath($cookie_file);

$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST,1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_fields);
curl_setopt($ch, CURLOPT_USERAGENT, $user_agent);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 1);

$result = curl_exec ($ch);
print ‘

Errors:
’ . curl_error($ch) . ‘

’;
curl_close($ch);
print ‘’ . $result . ‘’;
[/code]
:cool: Perl / MySQL / HTML+CSS

#7

Weird. Still doesn’t work…

The cookie is only one parameter, ndn_session_id_v3, correct? It’s being stored correctly in the cookie file, but when I go to grab a specific page of the admin panel (https://panel.dreamhost.com/index.cgi?tree=mail.addresses&), it shows me as not being logged in.

See anything wrong with my code? Would you be willing to host your (working) script on your server as a *.phps file?

[quote]<?
$url = ‘https://panel.dreamhost.com/index.cgi’;
$url2 = ‘https://panel.dreamhost.com/index.cgi?tree=mail.addresses&’;
$user_agent = ‘Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.1) Gecko/20060111 Firefox/1.5.0.1’;
$post_fields = ‘Nscmd=Nlogin&username=myuser&password=mypass’;
$cookie_file = ‘/home/myuser/whatever/cookies.txt’;
$cookie_file = realpath($cookie_file);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST,1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_fields);
curl_setopt($ch, CURLOPT_USERAGENT, $user_agent);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 1);
ob_start();
$return = curl_exec($ch);
ob_end_clean();
curl_close($ch);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url2);
curl_setopt($ch, CURLOPT_GET, 1);
curl_setopt($ch, CURLOPT_USERAGENT, $user_agent);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 1);
ob_start();
$return = curl_exec($ch);
ob_end_clean();
curl_close($ch);
echo $return;
?>[/quote]
Thanks.


#8

Still haven’t had any luck. Any help? :\