subscribe via PHP:curl
Posted: Fri Mar 28, 2008 9:04 am
I have a huge problem in implementing the subscribtion form on our website.
Our website is fully SSL protected, so transfering the users data from the subscribtion form to an uncrypted server (our OpenEMM-server) results in a warning message from the internet-browser. To workaround this warning I want to transfer the data in a server-to-server communication using PHP and curl.
On the first look it works good ... the recipients entries are made in OpenEMM ... also the german Umlaut problem with ISO -> UTF-8 I got solved. But OpenEMM doesn't send a double opt-in email to the recipient.
When I use a html-file local or on the server with the subscription form in it and apply to the warning message (sending unencryted data) the email was send by the OpenEMM server but not when sending the data through curl ... I have no ideas anymore.
I hope someone else have some!
the PHP code for sending the data is the following:
Our website is fully SSL protected, so transfering the users data from the subscribtion form to an uncrypted server (our OpenEMM-server) results in a warning message from the internet-browser. To workaround this warning I want to transfer the data in a server-to-server communication using PHP and curl.
On the first look it works good ... the recipients entries are made in OpenEMM ... also the german Umlaut problem with ISO -> UTF-8 I got solved. But OpenEMM doesn't send a double opt-in email to the recipient.
When I use a html-file local or on the server with the subscription form in it and apply to the warning message (sending unencryted data) the email was send by the OpenEMM server but not when sending the data through curl ... I have no ideas anymore.
I hope someone else have some!
the PHP code for sending the data is the following:
Code: Select all
$url = 'http://mail3.csl-computer.com/form.do';
$post_data = 'agnCI=1&agnFN=de_doi_confirm&agnSUBSCRIBE=1&agnMAILINGLIST=3&gender' . $_POST['gender'] . '&firstname=' . iconv("ISO-8859-15","UTF-8",$_POST['firstname']) . '&lastname=' . iconv("ISO-8859-15","UTF-8",$_POST['lastname']) . '&EMAIL=' . iconv("ISO-8859-15","UTF-8",$_POST['EMAIL']) . '&mailtype=' . $_POST['mailtype'];
$fp = tmpfile();
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_POST, TRUE);
curl_setopt($curl, CURLOPT_TIMEOUT, 20);
curl_setopt($curl, CURLOPT_FILE, $fp);
curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
curl_setopt($curl, CURLOPT_VERBOSE, 1);
curl_setopt($curl, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)");
curl_setopt($curl, CURLOPT_REFERER, "https://www.csl-computer.com/shop/shop_content.php?coID=21");
curl_setopt($curl, CURLOPT_FAILONERROR, TRUE);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, TRUE);
curl_setopt($curl, CURLOPT_COOKIEFILE, 'cookiefile');
curl_setopt($curl, CURLOPT_COOKIEJAR, 'cookiefile');
$status = curl_exec($curl);
$response['http_code'] = curl_getinfo($curl, CURLINFO_HTTP_CODE);
if ($status) {
$response['error'] = curl_error($curl);
$response['errno'] = curl_errno($curl);
}
curl_close($curl);
rewind($fp);
$response['data'] = '';
while ($str = fgets($fp, 4096)) {
$response['data'] .= $str;
}
fclose($fp);