Poměrně jednoduše použitelný pro odesílání e-mailů přes SMTP je PHPMailer.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
<?php require_once('phpmailer/Exception.php'); require_once('phpmailer/PHPMailer.php'); require_once('phpmailer/SMTP.php'); $MAIL = new PHPMailer\PHPMailer(TRUE); $to = array('psavec@email.cz'); $subject = "pokus"; $content_html = "To je test ěščřžýáíďťň"; try { $MAIL->setFrom('vas@email.cz', 'Jméno odesilatele'); $MAIL->CharSet = 'utf-8'; if (count($to)>=2) { $MAIL->addAddress($to[0]); $MAIL->addCC($to[1]); } else { $MAIL->addAddress($to[0]); } $MAIL->Subject = $subject; $MAIL->isHTML(TRUE); $MAIL->Body = $content_html; //$MAIL->AltBody = strip_tags($content_html); /* použijeme SMTP */ $MAIL->isSMTP(); /* SMTP server */ $MAIL->Host = 'smtp-141603.m3.wedos.net'; $MAIL->SMTPAuth = TRUE; /* Encryption */ $MAIL->SMTPSecure = 'tls'; /* SMTP username */ $MAIL->Username = 'vas@email.cz'; /* SMTP heslo */ $MAIL->Password = 'supertajneheslo'; /* SMTP port */ $MAIL->Port = 587; $result = $MAIL->send(); unset($MAIL); } catch (Exception $e) { echo $e->errorMessage(); } catch (\Exception $e) { /* PHP exception (note the backslash to select the global namespace Exception class). */ echo $e->getMessage(); } ?> |