Thank you for your attention! Well I do not have much familiarity with programming with just design. I tried the PHPMailer class to create a simple contact form on my site, I looked for some tips here but I did not have much success, because everything I saw was already a little early and I could not learn the basics ...
I installed the composer and installed phpmailer for it but crashed there and I could not go it alone, I ask for help here if someone points out what I'm doing wrong and how to fix it would thank you very much.
CONTACT.HTML
<form id="form" action="vendor/sendmail.php" method="post">
<div class="field">
<label class="label">Name</label>
<div class="control">
<input class="input" type="text" name="nome" placeholder="Name">
</div>
</div>
<div class="field">
<label class="label">Email</label>
<div class="control">
<input class="input" type="email" name="email" placeholder="Email">
</div>
</div>
<div class="field">
<label class="label">Message</label>
<div class="control">
<textarea class="textarea" name="mensagem" placeholder="Message"></textarea>
</div>
</div>
<div class="field is-grouped">
<div class="control">
<button class="button is-link">Submit</button>
</div>
</div>
</form>
SENDMAIL.PHP (I got exactly as I was in the documentation and just filled in my data)
$nome = $_POST["nome"];
$email = $_POST["email"];
$mensagem = $_POST["mensagem"];
// These must be at the top of your script, not inside a function
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
//Load Composer's autoloader
require 'autoload.php';
$mail = new PHPMailer(true); // Passing 'true' enables exceptions
try {
//Server settings
$mail->SMTPDebug = 2; // Enable verbose debug output
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'mail.eftmkg.com'; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = '[email protected]'; // SMTP username
$mail->Password = 'xxxxxxxxxxxx'; // SMTP password
$mail->SMTPSecure = 'tls'; // Enable TLS encryption, 'ssl' also accepted
$mail->Port = 587; // TCP port to connect to
//Recipients
$mail->setFrom('[email protected]', 'Mailer');
$mail->addAddress('[email protected]', 'Kaio Maia'); // Add a recipient
$mail->addAddress('[email protected]'); // Name is optional
$mail->addReplyTo('[email protected]', 'Info');
//$mail->addCC('[email protected]');
//$mail->addBCC('[email protected]');
//Attachments
$mail->addAttachment('/var/tmp/file.tar.gz'); // Add attachments
$mail->addAttachment('/tmp/image.jpg', 'new.jpg'); // Optional name
//Content
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = 'EFTMKG';
$mail->Body = '$mensagem';
//$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
$mail->send();
echo 'Message has been sent';
} catch (Exception $e) {
echo 'Message could not be sent. Mailer Error: ', $mail->ErrorInfo;
}
When I try to send I get the error message:
Could not access file: /var/tmp/file.tar.gz
Message could not be sent. Mailer Error: Could not access file: /var/tmp/file.tar.gz