Hye,
I'm trying to send HTML email using MAIL_mime PEAR module and having some trouble with embedded images. The email failed to send if the image is only embedded and not attach. But I don't want the image to be attached. Here is the code :

<?php
require_once "Mail.php";
require_once 'Mail/mime.php';

$html = <<<_HTML_
<html>
<head> 
<title>   </title> 
</head> 
<body bgcolor="#6699FF">
<p align="center">
<img src="logo.gif" width="70" height="30" >
</p>
</body>
</html>
_HTML_;

$from = " ";
$host = " ";
$username = " ";
$password = " ";
$crlf = "\n";


$headers = array (
	'From' => $from,
	'To' => $to,
	'Subject' => $subject
);


$mime = new Mail_mime($crlf);
$mime->setTXTBody($txt);
$mime->setHTMLBody($html);
$mime->addHTMLImage('/path/to/logo.gif', 'image/gif');
$mime->addAttachment('/path/to/logo.gif' , 'image/gif');

$msg = $mime->get();
$headers = $mime->headers($headers);

$smtp = Mail::factory('smtp',
  array ('host' => $host,
  'port' => 587,
  'auth' => true,
  'username' => $username,
  'password' => $password,
  'timeout' => 30)
);


$mail = $smtp->send($to, $headers, $msg);


if (PEAR::isError($mail)) {
  echo("<p>" . $mail->getMessage() . "</p>");
 } else {
  echo("<p>Message successfully sent!</p>");
 }

?>

When I comment "//$mime->addAttachment('/path/to/logo.gif' , 'image/gif');" and try to send emil only with addHTMLImage the script fails with the error message :

Fatal error: Call to undefined function: getresponse()in /usr/share/pear/Mail/smtp.php on line 338

Thank you for your help

    4 months later

    Check to make sure you have PEAR::NET_Socket installed and Mail_MIME is pointing to the correct location.

      Write a Reply...