this is a project to school but i dont know why its not working... I have the input fields , the first one is for my email , the second one is for my colleague email, then the subject and the body.... but when i fill the inputs it doesnt send the email....
This is my html...
<html>
<body>
<h2>Script done by Nuno Fernandes and Rafael</h2>
<form action="mail.php">
E-mail do sender:<br>
<input type="text" name="From"><br>
E-mail do receiver:<br>
<input type="text" name="addAddress"><br>
Assunto:<br>
<input type="text" name="Subject"><br>
Corpo do texto:<br>
<input type="text" name="Body" size="100"><br><br>
<input type="submit" value="Send">
</form>
</body>
</html>
and this is my php (that is called mail.php)
<?php
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
require_once "vendor/autoload.php";
//Cria o objeto
$mail = new PHPMailer(true);
//Dados de quem envia
$mail->From = $_POST['From'];
//Dados de quem vai receber
$mail->addAddress=$_POST['addAddress'];
//Se quiseres que a opção de reply funcione, metes aqui o email de reply
$mail->addReplyTo=$_POST['addReplyTo'];
//CC e BCC
//$mail->addCC("cc@example.com");
//$mail->addBCC("bcc@example.com");
//Isto determina se envias como texto normal ou se tens HTML a formatar o mail
$mail->isHTML(true);
$mail->Subject = $_POST['Subject']; // Assunto
$mail->Body = $_POST['Body']; // Mensagem
//$mail->AltBody = ""; // Isto é no caso de quereres ter html em cima e no fim do email uma versao em texto normal
try {
$mail->send();
echo "Message has been sent successfully";
} catch (Exception $e) {
echo "Mailer Error: " . $mail->ErrorInfo;
}
?>