eleith / emailjs

html emails and attachments to any smtp server with nodejs
MIT License
2.19k stars 230 forks source link

EmailJs not sending form data to my account #295

Closed Jay-Bruh closed 3 years ago

Jay-Bruh commented 3 years ago

Currently Im using "emailjs-com": "^3.2.0" and typescript for my project. I am following this tutorial to integrate it into my React project. My test emails are being sent to my account, but the data from the contact form on my website is not being sent. This is my current code:

import emailjs from 'emailjs-com';

export default function Team({ posts }) {
  function sendEmail(e) {
    e.preventDefault();

    emailjs.sendForm('gmail', 'template_9uw13mo', e.target, '//myUserid')
      .then((result) => {
          console.log(result.text);
      }, (error) => {
          console.log(error.text);
      });
      e.target.reset()
  }
  return (
    <>
      <div className="contact-container" style={{flexDirection:"row",backgroundColor:"#ECECEC"}}>
        <div style={{padding:"30px"}}>
          <div style={{flexDirection:"column"}}>
            <p style={{color:"#0E2043",backgroundColor:"#ECECEC", fontSize:"22px",fontWeight:"700", textAlign:"justify"}}>Your second citizenship. </p>
          </div>
        </div>
        <form onSubmit={sendEmail}>
        <div style={{padding:"30px"}}>
          <div>
          <div style={{padding:"5px"}}>
              <input style={{padding:"5px", width:"100%"}} type="text" placeholder="Name" name="name"/>
              </div>
            <div style={{width:"100%",display:"flex", flexWrap:"wrap", justifyContent:"space-between"}}>
            <div style={{padding:"5px"}}>
            <input style={{padding:"5px",width:"100%"}} type="text" placeholder="email" name="email"/>
            </div>
            <div style={{padding:"5px"}}>
            <input style={{padding:"5px",width:"100%"}} type="text" placeholder="phone" name="phone"/>
            </div>
            </div>
            <div style={{padding:"5px"}}>
              <input style={{padding:"5px", width:"100%"}} type="text" placeholder="Subject" name="subject"/>
              </div>

              <div style={{padding:"5px"}}>
              <textarea style={{padding:"5px", width:"100%"}} rows="4" placeholder="Message" name="message"/>
              </div>
              <div style={{padding:"5px"}}>
              <input style={{padding:"5px", width:"100%"}} type="submit" value="send message"></input>
              </div>
          </div>
        </div>
        </form>
      </div>
    </>
  );
}
eleith commented 3 years ago

please re-file this issue on https://github.com/emailjs-com a similarly named but different project