Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- use PHPMailer\PHPMailer\PHPMailer;
- use PHPMailer\PHPMailer\Exception;
- require 'vendor/autoload.php';
- $mail = new PHPMailer(true);
- $dotenv = new Dotenv\Dotenv(__DIR__);
- $dotenv->load();
- try {
- $login=getenv('MAILER_LOGIN');
- $password=getenv('MAILER_PASSWORD');
- $mail->SMTPDebug = 0;
- $mail->isSMTP();
- $mail->Host = 'smtp.gmail.com';
- $mail->SMTPAuth = true;
- $mail->Username = $login;
- $mail->Password = $password;
- $mail->SMTPSecure = 'tls';
- $mail->Port = 587;
- $email=$_POST['email'];
- $name=$_POST['name'];
- $phone=$_POST['phone'];
- $description=$_POST['description'];
- $who=$_POST['who'];
- $mail->setFrom($email);
- $mail->addAddress('hello@perseids.io');
- $mail->isHTML(true);
- $mail->Subject = 'Formularz kontaktowy perseids.io';
- $mail->Body= '<h3>Wiadomość z formularza aplikacyjnego</h3> <b>Email: </b>'.$email."<br/><br/> <b>Imię i nazwisko:</b> ".$name."<br/><br/> <b>Telefon</b>: ".$phone."<br/><br/> <b>Treść wiadomości:</b> ".$description."<br/><br/><b>Kto wypełnił:</b> ".$who;
- $mail->send();
- } catch (Exception $e) {
- echo 'Message could not be sent. Mailer Error: ', $mail->ErrorInfo;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement