I need a JavaScript code to send mail | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

I need a JavaScript code to send mail

the receiver mail id is our company's id. and the sender id is the user one who visits our site. i don't want to log them in to their mail domain. simply, user mail id : Subject: Text: (send button)

4th Feb 2017, 6:43 AM
Solomon Yelcin A
Solomon Yelcin A - avatar
5 Answers
+ 4
sending email via JavaScript only isn't possible. you'd have to compose the email and then open the user's standard email program. but that's not very elegant and doesn't save the user any time or effort. in PHP there's the mail() function which sends the email directly, so there's no need for external programs to open.
4th Feb 2017, 7:21 AM
Mario L.
Mario L. - avatar
+ 4
sure you can. just encapsulate your PHP code in <?php and ?> and make sure your server knows PHP.
4th Feb 2017, 8:34 AM
Mario L.
Mario L. - avatar
+ 2
ok... so i need to learn php also😬😬
4th Feb 2017, 9:04 AM
Solomon Yelcin A
Solomon Yelcin A - avatar
+ 1
Hey Solomon! Take a look at our service - emailjs.com. We built it to allow people sending email from Javascript by creating an email template (possibly with dynamic variables) and then trigger this email using a simple call to our Javascript library. Good luck!
4th Feb 2017, 1:10 PM
Sasha
0
can i use php code in an html page??? if yes i can use php also..
4th Feb 2017, 8:09 AM
Solomon Yelcin A
Solomon Yelcin A - avatar