ExactTarget订阅表单也发送表单详细信息

时间:2012-11-21 20:25:56

标签: php forms email exacttarget

目前有一个简报订阅表单,可以将信息提交给ExactTarget帐户。 是否可以使用相同的表单发送电子邮件,类似于PHP联系表单? 有一段时间,这是一个PHP形式。

我查看了丹佛的MailChimp订阅联系表格选项: Mail Chimp Subscribe In Contact Form

此表单不需要复选框即可订阅简报。

<form action="http://cl.exct.net/subscribe.aspx?lid=hidden" name="subscribeForm" method="post">  
<input type="hidden" name="thx" value="enewsletter-thank-you.php" />  
<input type="hidden" name="err" value="enewsletter-error.php" />  
<input type="hidden" name="MID" value="hidden" />

<ul class="contactForm">    
<li class="contactForm">
<label class="formFieldQuestion">E-mail Address:&nbsp;<span class="redrequired">*</span></label>
<input class="field-text" type="text" name="Email Address" size="20" value=""></li> 

<li class="contactForm">
<label class="formFieldQuestion">Full Name:</label>
<input class="field-text" type="text" name="Full Name" size="20" value=""></li>

<li class="contactForm">
<label class="formFieldQuestion">Company:</label>
<input class="field-text" type="text" name="Company or Organization" size="20" value=""></li>

<li style="padding-left:10px;">
<input id="saveForm" class="button_form" type="submit" value="Subscribe" name="submit"> </li>

</ul>
</form>

1 个答案:

答案 0 :(得分:2)

是的,您可以将此作为卷曲请求发送。将表单操作更改为mail_and_submit.php

然后,在mail_and_submit.php

//extract data from the post
extract($_POST);

//set POST variables
$url = 'http://cl.exct.net/subscribe.aspx?lid=hidden';
$fields = array(
            'thx' => urlencode($thx),
            'error' => urlencode($error),
            'MID' => urlencode($MID),
... (etc)
);

//url-ify the data for the POST
foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; }
rtrim($fields_string, '&');

//open connection
$ch = curl_init();

//set the url, number of POST vars, POST data
curl_setopt($ch,CURLOPT_URL, $url);
curl_setopt($ch,CURLOPT_POST, count($fields));
curl_setopt($ch,CURLOPT_POSTFIELDS, $fields_string);

//execute post
$result = curl_exec($ch);

//close connection
curl_close($ch);

然后,使用相同的字段构建电子邮件,并发送,例如:

$message = 'A post was submitted:<br/>';
$message .= 'thx: ' . $thx;
$message .= 'error: ' . $error;
$message .= 'MID: ' . $mid;

...等,然后邮寄:

mail('some-email@address.com', 'Your Entry', $message);