【问题标题】:Why email js not sending mail when using from react app?为什么从 React 应用程序使用时电子邮件 js 不发送邮件?
【发布时间】:2022-11-14 02:45:09
【问题描述】:

当我从我的反应应用程序联系我们页面发送电子邮件时,电子邮件 js 没有发送任何电子邮件,尽管当我从网站本身对其进行测试时电子邮件工作正常。这是我使用的电子邮件 js 的代码。我已经删除了不必要的部分。

function Contactme() {
  const form = useRef();
  function sendEmail(e){
    emailjs.sendForm('gmail', 'template_ppq****', form.current, 'iWxx2qNPr0xxu****')
    .then((result) => {
        console.log(result.text);
    }, (error) => {
        console.log(error.text);
    });
    e.target.reset();
  }
  return (
    <div>
      <div className="contact-box">
        <div className="details">
          <h2>Contact</h2>
          <p>Fill up the form to contact</p>
        </div>
        <div className="sendmsg">
          <form action="" onSubmit={sendEmail} ref={form}>
          <div className="contact-right name-input" name="name">
          Your Name
          <input type="text" className="contact-right-input email-input" name="from_name" />
          Your email
          <input type="text" className="contact-right-input message-input" name="email"/>
          Subject
          <input type="text" className="contact-right-input message-input" name="subject"/>
          Your message
          <textarea id="" cols="30" rows="10" style={{border:"1px solid lightblue"}} name="message"></textarea>
          <button className="contact-btn" >Submit</button>
          </div>
          </form>
        </div>
      </div>
    </div>
  )
}

【问题讨论】:

  • 你解决了吗?因为我面临同样的问题

标签: html css reactjs email


【解决方案1】:

在您的输入字段中添加一个 ID,并确保该 ID 与您的 Emailjs 仪表板上的设置相同。我希望这有帮助

【讨论】:

    【解决方案2】:

    这对我有用。在 emailjs.sendForm('gmail'.......... 而不是 'gmail' 使用您的服务 IDthis one

    【讨论】:

      猜你喜欢
      • 2020-05-24
      • 1970-01-01
      • 1970-01-01
      • 2010-12-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-01-12
      • 1970-01-01
      相关资源
      最近更新 更多