1

目前有一个时事通讯订阅表单,可将​​信息提交到 ExactTarget 帐户。是否可以让相同的表单发送电子邮件,类似于 PHP 联系表单?曾经这是一种 PHP 表单。

我确实查看了丹佛的 MailChimp 在联系表中订阅选项: Mail Chimp 在联系表中订阅

此表单不需要复选框即可订阅时事通讯。

<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>
4

1 回答 1

2

是的,您可以将其作为 curl 请求发送。将您的表单操作更改为类似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);
于 2012-11-21T20:41:14.853 回答