-
[Email js] 웹사이트에서 Email 보내는 방법Reactjs 2023. 7. 28. 06:49
1. emailjs.com 접속하여 Sign up
2. 'Add New Service'로 신규 생성
3. 'Connect Account'로 계정 연결하고 'Create Service' 클릭
4. Email Templates에서 'Create New Template' 클릭하고 기본적인 메세지 형식을 결정
5. 웹사이트에 입력할 API Key, Service ID, Template ID 위치
- Account에서 API Key 확인
- Email Services 탭에서 Service ID 확인
- Email Templates 탭에서 Template ID 확인
6. Submit 버튼에 아래 코드 입력 (해당 Key, ID 에 맞게 입력)
const handleSubmit = (e) => { e.preventDefault(); setLoading(true); emailjs .send( 'EMAILJS_SERVICE_ID', 'TEMPLATE_ID', { from_name: form.name, to_name: "JavaScript Mastery", from_email: form.email, to_email: "sujata@jsmastery.pro", message: form.message, }, 'EMAILJS_PUPLIC_KEY' ) .then( () => { setLoading(false); alert("Thank you. I will get back to you as soon as possible."); setForm({ name: "", email: "", message: "", }); }, (error) => { setLoading(false); console.error(error); alert("Ahh, somthing went wrong. Please try again."); } ); }
'Reactjs' 카테고리의 다른 글
[Javascript] Zustand (0) 2023.07.16