I’m trying to send mail using phpMailer. It’s my code:
<?php
require_once('phpmailer/class.phpmailer.php');
$mail = new PHPMailer(true);
$mail->PluginDir = "phpmailer/";
$mail->IsSMTP();
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->SMTPSecure = "ssl"; // sets the prefix to the servier
$mail->Host = "smtp.gmail.com";
$mail->Port = 465;
$mail->Username = "xxx@gmail.com";
$mail->Password = "xxxxx";
$mail->SetFrom('yyyya@gmail.com', 'Nasze imie i nazwisko');
$mail->AddAddress("email@anymail.pl"); // ADRESAT
$mail->Subject = 'Test message';
// w zmienną $text_body wpisujemy treść maila
$text_body = "Hello, \n\n";
$text_body .= "Sending succesfully, \n";
$text_body .= "PHPMailer";
$mail->Body = $text_body;
if(!$mail->Send())
echo "There has been a mail error <br>";
echo $mail->ErrorInfo."<br>";
// Clear all addresses and attachments
$mail->ClearAddresses();
$mail->ClearAttachments();
echo "mail sent <br>";
?>
Mail didn’t send and in browser i have empty page, without message. What is here wrong?
Best regards,
Dagna
Try setting error checking on (for development only):
Put above two lines on top of your page. This should give you some message now eg what error is coming up exactly.
update
I modified the
class.smtp.phpfile’sConnectfunction like this to get it working for myself:And my email sending code was which works is;