Ako nastavím v php.ini overovanie smtp servera

Z www.yegon.info
Prejsť na: navigácia, hľadanie

SMTP autentifikáciu v php.ini nedocielite žiadnym spôsobom. V peare sú knižnice, ktoré tuto možnosť vedia využívať, poskytujeme Vám link na manuál pre pear :


Priklad:

<?php
require_once('Mail.php');
require_once('Mail/mime.php');
 
$from = "web@yegon.sk";
$subject = "Subject";
$email = "prijemca@gmail.com";
$admin_mail = "admin@yegon.sk";
 
$smtp_server = "smtp.yegon.sk";
$smtp_auth = TRUE;
$smtp_user = "login";
$smtp_pass = "password";
 
$txtmail = "text";
 
if (strlen($email) > 3) {
    $crlf = "\r\n";
    $hdrs = array(
        'From'    => $from,
        'Subject' => $subject,
        'To'      => $email,
        'Date'    => date("r"),
    );
 
    $mime = new Mail_mime($crlf);
    $mime->setTXTBody($txtmail);
 
    $mimeparam = array(
        'text_charset' => 'windows-1250',
        'head_charset' => 'windows-1250',
        'html_charset' => 'windows-1250',
        'text_encoding' => '8bit',
    );
 
    $body = $mime->get($mimeparam);
    $hdrs = $mime->headers($hdrs);
    $param =array(
        "host" => $smtp_server,
        "port" => "25",
        "auth" => $smtp_auth,
        "username" => $smtp_user,
        "password" => $smtp_pass
    );
 
    try {
       $mail =& Mail::factory("smtp",$param);
       $mail->send($email, $hdrs, $body));
    } catch(PEAR_Exception $e) {
       try {
          $mail =& Mail::factory("sendmail");
          $mail->send($email, $hdrs, $body));
       } catch (PEAR_Exception $e) {
          @mail($admin_mail,$subject, "Nevedel poslat na $email");
       }
    }
}
?>
Osobné nástroje