1

現在、ExactTargetアカウントに情報を送信するニュースレター購読フォームがあります。PHPの連絡フォームと同じように、同じフォームでメールを送信することはできますか?かつてこれはPHPフォームでした。

デンバーのMailChimpサブスクライブインコンタクトフォームオプションを確認しました:MailChimpサブスクライブ インコンタクトフォーム

このフォームでは、ニュースレターを購読するためのチェックボックスは必要ありません。

<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 に答える