I am stack with my form. I have to send value on e-mail. I don't know php, I know just JS(html, css). I have a very simple file structure, just html, css (a bit JS). I don't have any package manager. I have to do my form with php. -I found example, put php code on the top of my html file. -Added .htaccess file How I understand I need to use Apache as well, or not? I don't have any idea about php - right me please some instruction what I have to do in simple way.
Asked
Active
Viewed 43 times
0
-
1If you want a full client side solution you can use mail API services, see https://stackoverflow.com/questions/41785727/send-emails-via-mailjet-without-backend – Adrien Mar 01 '19 at 22:41
-
I can't use services. I have to do it myself with php – Noa Mar 01 '19 at 23:05
-
In this case you need to learn PHP a little. You will also need a server to run your PHP code (either Apache, PHP built-in server or other servers). You can check out the documentation at http://php.net/manual/en/ – Adrien Mar 01 '19 at 23:14
-
I would highly recommend [PHPMailer](https://github.com/PHPMailer/PHPMailer). It can be "installed" without the use of any package manager, following the instructions on GitHub. PHP also has a [built-in mail() function](http://php.net/manual/en/function.mail.php), but I would not recommend it as it has some deliverability issues – tshimkus Mar 02 '19 at 00:01
1 Answers
0
You can use PHPMailer to send emails easily. First you need to know how to get post data in PHP. and then store them as new variables then add them in Mail body to send.
Link for the PHPMailer: https://github.com/PHPMailer/PHPMailer
Tutorial for PHPMailer: https://github.com/PHPMailer/PHPMailer/wiki/Tutorial
You have to provide your email and password details in PHPMailer Library Finally, Your PHP code be like below
<?php
require 'PHPMailerAutoload.php';
$name = $_POST['name'];
$email = $_POST['email'];
$mail = new PHPMailer;
$mail->setFrom('from@example.com', 'Your Name');
$mail->addAddress($email, 'My Friend');
$mail->Subject = 'First PHPMailer Message';
$mail->Body = " Hi! $name This is my first e-mail sent through PHPMailer.';
if(!$mail->send()) {
echo 'Message was not sent.';
echo 'Mailer error: ' . $mail->ErrorInfo;
} else {
echo 'Message has been sent.';
}

bairavand
- 335
- 3
- 11