У меня тоже не заработало под вин(.mit писал(а): ↑Пт сен 07, 2018 2:15 pmДоброго всем времени суток.
У меня почему то не получилось. Вызываю SendMail и SendMail_html, всё вроде как выполняется, но письма не приходят. Видимо и не уходят.
У меня система устанавливалась в мае 2018. Обнаружил в папке apps приложение miniRelay. Само приложение судя по логам последний раз отрабатывало в 2012 году. Нигде в настройках, коде и файлах конфигурации не обнаружил ничего связанного с miniRelay. Прошу направить в правильное русло - где искать настройки и как победить проблему.
Установил phpmailer https://github.com/PHPMailer, написал функцию mySendMail( $to,$from, $subj, $body, $attach=""), шлёт через мой яндекс-ящик, можно добавлять аттачи, проблем с кодировкой нет.
Предполагается, что папка PHPMailer лежит в lib
Настройки внутри - для Яндекса,
плюс логин/пароль для Я-почты:
gg('Sergey.YaMailAddress')
gg('Sergey.YaPassword')
Example: mySendMail('JonDow@gmail.com','Alice', 'тест', 'проба письма');
Код: Выделить всё
function mySendMail($to,$from,$subj,$body,$att=null)
{
require_once 'lib/PHPMailer/PHPMailerAutoload.php';
//Create a new PHPMailer instance
$mail = new PHPMailer;
$mail->setLanguage('ru', 'lib/PHPMailer/language/');
//Tell PHPMailer to use SMTP
$mail->isSMTP();
//Enable SMTP debugging
// 0 = off (for production use)
// 1 = client messages
// 2 = client and server messages
$mail->SMTPDebug = 0;
//Ask for HTML-friendly debug output
$mail->Debugoutput = 'html';
//Set the hostname of the mail server
$mail->Host = 'smtp.yandex.com';
//Set the SMTP port number - 587 for authenticated TLS, a.k.a. RFC4409 SMTP submission
$mail->Port = 587;
//Set the encryption system to use - ssl (deprecated) or tls
$mail->SMTPSecure = 'tls';
//Whether to use SMTP authentication
$mail->SMTPAuth = true;
$mail->CharSet = "UTF-8";
//Username to use for SMTP authentication - use full email address
$mail->Username = gg('Sergey.YaMailAddress');
//Password to use for SMTP authentication
$mail->Password =gg('Sergey.YaPassword');
//Set who the message is to be sent from
$mail->setFrom(gg('Sergey.YaMailAddress'), $from);
//Set an alternative reply-to address
//$mail->addReplyTo('replyto@example.com', 'First Last');
//Set who the message is to be sent to
$mail->addAddress($to);
//Set the subject line
$mail->Subject = $subj;
$mail->Body = $body ;
//Attach a file
if (isset($att)){
$mail->addAttachment($att);
}
//send the message, check for errors
if (!$mail->send()) {
return "Ошибка почты: " . $mail->ErrorInfo;
} else {
return "Письмо отправлено";
}
}