2015-06-21 112 views

回答

1

您提供的文件僅用於驗證表單。因此,如果您需要發送電子郵件,則必須使用服務器端運行的另一種腳本語言,如php。在該文件中寫下所有必需的代碼以發送電子郵件。例如,我使用這段代碼。

<?php 
///subscribe form 
    $recipient = "[email protected]"; /// Your Email address 
    if (isset($_POST['email'])){ 
     //Send Mail To Webmaster 
     $email = $_POST['email'] ; 
     $subject = 'The subject'; 
     $message = $email . ' The message .'; 
     mail("$recipient", $subject, $message, "From:" . $recipient); 
    } 
?> 

很明顯,您必須通過ajax發送變量或直接使用表單的post方法發送變量。

+0

這會很簡單,因爲添加表單action =「mailto:[email protected]」和method =「post」正確嗎? – user3097331

+1

只是'method ='post'',因爲mailto會打開一個新的郵件窗口。例如,假設我在表單聲明中命名了php文件「mail.php」:'method = post action = mail.php' –