Skip to content

Instantly share code, notes, and snippets.

@yunusga
Last active December 16, 2016 09:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yunusga/e2997679ee824870ea42 to your computer and use it in GitHub Desktop.
Save yunusga/e2997679ee824870ea42 to your computer and use it in GitHub Desktop.
Wordpress SMTP support if php mail() not work
<?php
// для примера, настройки Яндекса
add_action('phpmailer_init','send_smtp_email');
function send_smtp_email( $phpmailer ) {
// Define that we are sending with SMTP
$phpmailer->isSMTP();
// The hostname of the mail server
$phpmailer->Host = "smtp.yandex.ru";
// Use SMTP authentication (true|false)
$phpmailer->SMTPAuth = true;
// SMTP port number - likely to be 25, 465 or 587
$phpmailer->Port = "465";
// Username to use for SMTP authentication
$phpmailer->Username = "chtoto@yandex.ru";
$phpmailer->From = "chtoto@yandex.ru"; // должен соответствовать $phpmailer->Username
$phpmailer->FromName = "от кого Имя или что то другое";
// Password to use for SMTP authentication
$phpmailer->Password = "password";
// The encryption system to use - ssl (deprecated) or tls
// теперь Яндекс не гарантирует корректной работы SMTP без ssl
$phpmailer->SMTPSecure = "ssl";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment