Короче, установить PEAR-пакеты получилось, но это проблемы не решает, так как код не работает.
[PHP]include 'Mail.php'; // PEAR Mail package
include 'Mail/mime.php'; // PEAR Mail_Mime packge
$from = "*****@yandex.ru";//подставьте свой
$to = "*****@gmail.com";//подставьте
$subject = 'Test mime message with an attachment';
$headers = array ('From' => $from,'To' => $to, 'Subject' => $subject);
$text = 'Text version of email'; // text and html versions of email.
$html = '<html><body>HTML version of email. <strong>This should be bold</strong></body></html>';
$file = 'sample.txt'; // attachment
$crlf = "\n";
$mime = new Mail_mime($crlf);
$mime->setTXTBody($text);
$mime->setHTMLBody($html);
$mime->addAttachment($file, 'text/plain');
//do not ever try to call these lines in reverse order
$body = $mime->get();
$headerss = $mime->headers($headers);
$host = "smtp.yandex.ru";
$username = "*****@yandex.ru";//подставить свой логин
$password = "*****";//подставить свой пароль
$smtp = Mail::factory('smtp', array ('host' => $host, 'auth' => true,
'username' => $username,'password' => $password));
$mail = $smtp->send($to, $headerss, $body);
if (PEAR::isError($mail)) {
echo("<p>" . $mail->getMessage() . "</p>");
}
else {
echo("<p>Message successfully sent!</p>");
}/PHP]
|