Когда я пытаюсь отправить почту через PHPMailer, я получаю это сообщение об ошибке. Мой код ниже:
<?
require("phpmailer/class.phpmailer.php"); // First we require the PHPMailer libary in our script
$mail = new PHPMailer(); // Next we create a new object of the PHPMailer called $mail
$mail->From = "rajasekar.kcet@gmail.com";
$mail->FromName = "Rajasekar";
$mail->AddAddress("rajasekar.kcet@gmail.com"); // This is the adress to witch the email has to be send.
$mail->Subject = "First PHP Email message"; // This is the subject of the email message.
$mail->Body = "Hi! \n\n This is my first e-mail sent through PHP."; // This is the actual email message
if(!$mail->Send()) // Now we send the email and check if it was send or not.
{
echo 'Message was not sent.';
echo 'Mailer error: ' . $mail->ErrorInfo;
}
else
{
echo 'Message has been sent.';
}
?>
Убедитесь, что вы также включили smtp класс, который поставляется с phpmailer:
// for mailing
require("phpmailer/class.phpmailer.php");
require("phpmailer/class.smtp.php");
Попробуйте с адресом, который не является gmail. Они не разрешают (насколько я знаю) быстрый доступ для отправки почты. На прошлой неделе я делал простую почтовую программу, и они также не используют порты по умолчанию для отправки и требуют, чтобы вы пересылали почту по https
."Could not instantiate mail function" - это способ PHPMailer сообщить, что вызов mail() (в расширении Mail) не удался. (Значит, вы используете 'mail' mailer.)
Вы можете попробовать убрать @s перед вызовом mail() в PHPMailer::MailSend и посмотреть, какие ошибки отбрасываются.