Portál AbcLinuxu, 12. května 2025 08:43
Napisal som nasledujuci kod:
<?
include "class.phpmailer.php";
//nastavenie
$mail = new PHPMailer(true);
$mail->Charset = "utf-8";
$mail->SetLanguage("sk", "/");
$mail->IsSMTP();
$mail->SMTPAuth = true;
$mail->Host = "smtp.gmail.com";
$mail->SMTPSecure = "ssl";
$mail->Port = 465;
$mail->Priority = 3;//normalna
$mail->ContenType = 'text/plain';
$mail->Encoding = "8-bit";
$mail->Sender = "MAIL FROM";//smtp
$mail->Subject = "predmet";
$mail->Body = "blasgdfgdfg";
$mail->AltBody = "blabla";//alternativa ked nevie citat HTML
$mail->WordWrap = 50;
$mail->Mailer = "smtp";
$mail->From = "rastislav.rabatin@gmail.com";
$mail->FromName = "Rastislav Rabatin";
$mail->AddAddress("rastislav.rabatin@gmail.com");
$mail->IsHTML(true);
$mail->Username = "rastislav.rabatin@gmail.com";
$mail->Password = "heslo";
//posielame
if ($mail->Send()):
return true;
else:
$chyba = $mail->ErrorInfo;
return false;
endif;
?>
snazim sa pomocou gmailu odoslat postu,ale bohuzial nedojde obsah spravy.V com je chyba?
Dik za pomoc.
$chyba
?
Tu je chyba:
Fatal error: Uncaught exception 'phpmailerException' with message 'SMTP Error: Could not authenticate.' in /var/www/class.phpmailer.php:699 Stack trace: #0 /var/www/class.phpmailer.php(613): PHPMailer->SmtpConnect() #1 /var/www/class.phpmailer.php(516): PHPMailer->SmtpSend('Date: Tue, 1 Se...', '') #2 /var/www/skuska.php(30): PHPMailer->Send() #3 {main} thrown in /var/www/class.phpmailer.php on line 699
SMTP Error: Could not authenticate.V PHP ti nefunguje posílání mailů. Mrkni do sekce
[mail function]
v php.ini.
Toto tam mam:
[mail function]
; For Win32 only.
SMTP = localhost
smtp_port = 25
; For Win32 only.
;sendmail_from = me@example.com
; For Unix only. You may supply arguments as well (default: "sendmail -t -i").
;sendmail_path =
; Force the addition of the specified parameters to be passed as extra parameters
; to the sendmail binary. These parameters will always replace the value of
; the 5th parameter to mail(), even in safe mode.
;mail.force_extra_parameters =
Uz som nasiel chybu. Napisal som zle heslo,ale stale sa neodoslal obsah mailu. Dojde iba premet a meno odosielatela.
Tiskni
Sdílej:
ISSN 1214-1267, (c) 1999-2007 Stickfish s.r.o.