Показать сообщение отдельно

  #289  
Старый 02.08.2007, 14:49
Krueger
Новичок
Регистрация: 07.10.2005
Сообщений: 13
С нами: 10837966

Репутация: 10
По умолчанию

Цитата:
Сообщение от Uruck-Buhay  
Если кому не лень,скажите пожалуйста,как добавить приложение файла к отправке письма на мыло?
http://pear.php.net/package/Mail_Mime
качаем отсюда пакет и пишем код подобный примеру:
Код:
<?php
include('Mail.php');
include('Mail/mime.php');

$text = 'Text version of email';
$html = '<html><body>HTML version of email</body></html>';
$file = '/home/richard/example.php';
$crlf = "\n";
$hdrs = array(
              'From'    => 'you@yourdomain.com',
              'Subject' => 'Test mime message'
              );

$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();
$hdrs = $mime->headers($hdrs);

$mail =& Mail::factory('mail');
$mail->send('postmaster@localhost', $hdrs, $body);
?>
При необходимости меняем
Код:
$mime->addAttachment($file, 'text/plain');
на
Код:
$mime->addHTMLImage ($file, 'image/jpeg');
или аналогичное.
 
Ответить с цитированием