Since I do not want to use the mail()
function, I decided to move to PHPMailer.
So yes, I am new to it. But I keep getting errors:
'Notice: Undefined index: email' 'Notice: Undefined index: nume' 'Notice: Undefined variable: mail' but they're already declared in my html file.
Another error is from PHPMailer, which states
'Fatal error: Uncaught Error: Call to a member function setFrom() on null'.
Does someone know how to solve this please?
Thank you in advance!
Here is my form
<form action="mailer.php" method="post">
<input type="text" name="materie" class="textb" placeholder="Materia" required></input>
<h1>Pentru a uploada imagini, va rog sa dati click <a href="https://imgur.com/upload?beta" target="_" class="hmod">aici</a></h1>
<h1>Dupa aceea, dati click pe "Selectati imaginea" sau "Choose image"</h1>
<h1>Odata selectata imaginea, o sa va dea intr-un meniu.</h1>
<h1>In acel meniu, ce va trebui sa faceti este astfel: Da-ti click pe "Ascuns" sau "Hidden"</h1>
<h1>Perfect! Copiati linkul si introduceti-l in textbox</h1>
<input type="text" name="link1" style="width: 300px;" class="textb" placeholder="Plasati linkul 1 aici" required><br />
<input type="text" name="link2" style="width: 300px;" class="textb" placeholder="Plasati linkul 2 aici"><br />
<input type="text" name="link3" style="width: 300px;" class="textb" placeholder="Plasati linkul 3 aici"><br />
<h1>Introduceti e-mailul dvs</h1>
<input type="text" style="width: 300px;" class="textb" placeholder="Aici" name="email"><br />
<input type="text" name="nume" placeholder="Introduceti-va numele" style="width: 300px;" class="textb" required> <br />
<h1>Cand apasati pe "Trimiteti", o sa se deschida o fereastra.</h1>
<h1>Tot ce trebuie sa faceti este sa:</h1>
<ol>
<li>va introduceti emailul</li>
<li>dati click pe butonul de send/trimitere</li>
</ol>
<input type="submit" class="sub" value="Trimiteti">
<h1>Bafta si Spor!</h1>
</form>
and my mailer.php
<?php
use PHPMailer\PHPMailer\PHPMailer;
require 'autoload.php';
$email = $_POST['email'];
$mat = $_POST['materie'];
$name = $_POST['nume'];
$link1 = $_POST['link1'];
$link2 = $_POST['link2'];
$link3 = $_POST['link3'];
$to = 'ioana.palas@yahoo.com';
$rec = 'Doamna Diriginta';
$email = new PHPMailer();
$mail -> setFrom($email, $name);
$mail -> addAddress($to, $rec);
$mail -> Body = $link1 . '<br>' . $link2 . '<br>' . $link3 . '<br>';
$mail -> Subject = 'Teme: '.$mat;
$mail->send();
if(!$mail -> send()) {
echo $email->ErrorInfo;
}
?>
Sorry if it bothers you. I had to do it in Romanian.