Witam nie działa mi phpmailer nie wysyła mi e-maila z serwera mailtrap strona się w ogóle nie ładuje. o to script.`<?php
/* php milner */
require DIR . ‘/…/vendor/autoload.php’;
/echo DIR;/
/echo działa_trapmail;/
function send_mail($config)
{
$mail = new PHPMailer;
//$mail ->mailError = 3;
$mail->CharSet = ‘UTF-8’;
$mail->isSMTP (); // Set mailer to use SMTP
$mail->Host = ‘smtp.mailtrap.io’; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = ‘d7193513a3f1c1’; // SMTP username
$mail->Password = ‘b322e4b4e6ab04’; // SMTP password
$mail->SMTPSecure = ‘tls’; // Enable TLS encryption, ssl
also accepted
$mail->Port = 2525; // TCP port to connect to
$mail->setFrom('wiktorski84@gmail.com', 'maciej');
$mail->addAddress('wiktorski84@gmail.com', 'maciej'); // Add a recipient
$mail->AddReplyTo('wiktor10-93@o2.pl', 'Reply to name');
// $mail->addAddress('ellen@example.com'); // Name is optional
$mail->addReplyTo($config->from_email, $config->from_name);
// $mail->addCC('cc@example.com');
// $mail->addBCC('bcc@example.com');
$mail->addAttachment('/var/tmp/file.tar.gz'); // Add attachments
$mail->addAttachment(’/tmp/image.jpg’, ‘new.jpg’); // Optional name
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = $config->mail_subject;
$mail->Body = $config->mail_body;
$html = new \Html2Text\Html2Text($mail->Body);
$mail->AltBody = $html->getText();
if(!$mail->send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
echo 'Message has been sent';
}
}
if ($_SERVER[‘REQUEST_METHOD’] === ‘POST’) {
$config = (object) [
'from_email' => $_POST['from_email'],
'from_name' => $_POST['from_name'],
'mail_subject' => $_POST['mail_subject'],
'mail_body' => $_POST['mail_body'],
];
send_mail($config);
}
?>`