HtmlMimeMail: E-mail doesn't contain subparts
From FVue
(Redirected from HtmlMimeMail: e-mail doesn't contain parts)
Contents
Problem
I'm trying to send HTML e-mails using htmlMimeMail-2.5.2. When I'm sending e-mails however, certain parts – or even the whole body – are missing.
Steps to reproduce the problem
- Send an e-mail using the provided example.1.php
- Notice the received e-mail is missing the file `background.gif'
Environment
- Debian-4.0
- Php-4.4.4
Solution
Patch htmlMimeMail.php
htmlMimeMail-2.5.2 has a bug regarding PHP references. Also a noticed is fixed if SERVER_NAME is not available. htmlMimeMail-2.5.2 should be patched:
--- htmlMimeMail.php.orig 2007-12-07 12:54:02.000000000 +0100
+++ htmlMimeMail.php 2007-12-07 13:29:44.000000000 +0100
@@ -409,7 +409,7 @@
$params['encoding'] = $this->build_params['text_encoding'];
$params['charset'] = $this->build_params['text_charset'];
if (is_object($obj)) {
- $return = $obj->addSubpart($text, $params);
+ $return =& $obj->addSubpart($text, $params);
} else {
$return = new Mail_mimePart($text, $params);
}
@@ -426,7 +426,7 @@
$params['encoding'] = $this->build_params['html_encoding'];
$params['charset'] = $this->build_params['html_charset'];
if (is_object($obj)) {
- $return = $obj->addSubpart($this->html, $params);
+ $return =& $obj->addSubpart($this->html, $params);
} else {
$return = new Mail_mimePart($this->html, $params);
}
@@ -452,7 +452,7 @@
{
$params['content_type'] = 'multipart/alternative';
if (is_object($obj)) {
- $return = $obj->addSubpart(, $params);
+ $return =& $obj->addSubpart(, $params);
} else {
$return = new Mail_mimePart(, $params);
}
@@ -467,7 +467,7 @@
{
$params['content_type'] = 'multipart/related';
if (is_object($obj)) {
- $return = $obj->addSubpart(, $params);
+ $return =& $obj->addSubpart(, $params);
} else {
$return = new Mail_mimePart(, $params);
}
@@ -629,7 +629,7 @@
// Add message ID header
srand((double)microtime()*10000000);
- $message_id = sprintf('<%s.%s@%s>', base_convert(time(), 10, 36), base_convert(rand(), 10, 36), !empty($GLOBALS['HTTP_SERVER_VARS']['HTTP_HOST']) ? $GLOBALS['HTTP_SERVER_VARS']['HTTP_HOST'] : $GLOBALS['HTTP_SERVER_VARS']['SERVER_NAME']);
+ $message_id = sprintf('<%s.%s@%s>', base_convert(time(), 10, 36), base_convert(rand(), 10, 36), !empty($GLOBALS['HTTP_SERVER_VARS']['HTTP_HOST']) ? $GLOBALS['HTTP_SERVER_VARS']['HTTP_HOST'] : !empty($GLOBALS['HTTP_SERVER_VARS']['SERVER_NAME']) ? $GLOBALS['HTTP_SERVER_VARS']['SERVER_NAME'] : 'localhost');
$this->headers['Message-ID'] = $message_id;
$this->is_built = true;
Patch smtp.php
smtp.php can also be patched to prevent this PHP Notice:
Notice: Only variable references should be returned by reference in /home/freddy/proj/htmlMimeMailBug/smtp.php on line 94
Patch:
--- smtp.php.orig 2007-12-07 11:21:06.000000000 +0100
+++ smtp.php 2007-12-07 12:57:16.000000000 +0100
@@ -91,7 +91,8 @@
$greeting = $this->get_data();
if(is_resource($this->connection)){
- return $this->auth ? $this->ehlo() : $this->helo();
+ $return = $this->auth ? $this->ehlo() : $this->helo();
+ return $return;
}else{
$this->errors[] = 'Failed to connect to server: '.$errstr;
return FALSE;
@@ -356,4 +357,4 @@
}
} // End of class
-?>
\ No newline at end of file
+?>
Journal
20071207
Send an e-mail to http://www.phpguru.org – the HtmlMimeMail maintainer – with patches and the suggestion of creating a htmlMimeMail-2.5.3 release.
Advertisement