2017-12-10 10 views
0

私はReact Formを使用して、基本的なReactのランディングページに連絡フォームを作成します。ユーザーがsubmitを押すと、特定のメールアドレス(例:[email protected])。これがルーキーの質問であれば私は辛いですが、答えが見つからないようです!反応形式を使用して特定の電子メールアドレスにフォームデータを送信

//the state 
constructor(props) { 
super(props); 
//this.handleSubmit = this.handleSubmit.bind(this); 
this.state = {}; 

}

//the form 
<Form onSubmit={submittedValues => this.setState({ submittedValues })}> 
     { formApi => (
      <form onSubmit={formApi.submitForm} id="form2"> 
      <label htmlFor="firstName">First name</label> 
      <Text field="firstName" id="firstName" /> 
      <label htmlFor="lastName">Last name</label> 
      <Text field="lastName" id="lastName" /> 
      <label htmlFor="email">Email"</label> 
      <Text field="email" id="email" /> 
      <label htmlFor="subject">Subject</label> 
      <Text field="subject" id="subject" /> 
      <label htmlFor="message">Message</label> 
      <TextArea field="message" id="message" /> 
      <button type="submit" className="mb-4 btn btn-primary">Submit</button> 
      </form> 
     )} 
     </Form> 

答えて

0

次の手順を実行して、これを行うことができます:あなたはバックエンド(サーバー側)のスクリプトを必要とするすべての

  1. まずどのどのデータを渡しても電子メールを送信します。
  2. 第2に、サーバー側でそのスクリプトにAjaxリクエストを送信し、電子メールで送信する必要があるすべてのデータを渡す必要があります。

あなたがPHPのメール機能を使用するかはあなたの選択の任意のライブラリを使用することができ、サーバー側のPHPを使用している場合。

関連する問題