Thanks Guys, I really do appreciate the help.

I agree, I don't like leaving it like that. either.
I'm calling the $address object as follows:

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
set_include_path( "/usr/include/php/ezcomponents-2007.1.1:" . ini_get( "include_path" ) ); require_once "Base/src/base.php"; // dependent on installation method, see below
function __autoload( $className )
{
    ezcBase::autoload( $className );
}


class myConverter
{
public static function convertToUTF8IconvNoNotices( $text, $originalCharset )
    {
if ( $originalCharset === 'unknown-8bit' || $originalCharset === 'x-user-defined' )
        {
            $originalCharset = "latin1";
        }
        return @iconv( $originalCharset, 'utf-8', $text );
    }
}

$pop3 = new ezcMailPop3Transport( "mail.domain.com" );
$pop3->authenticate( "[EMAIL PROTECTED]", "pass" );

$set = $pop3->fetchAll(true);

$parser = new ezcMailParser();
ezcMailCharsetConverter::setConvertMethod( array( 'myConverter', 'convertToUTF8IconvNoNotices' ) );

$mails = $parser->parseMail( $set );

//print_r($mail);

foreach ( $mails as $mail )
{
        $from = formatAddress( $mail->from );
        $to = formatToAddress( $mail->to );
// hack // some mail from users comes with FROM header blank but reply-to is populated (YUCK)
        if ($from == "") $from = formatAddress( $mail->returnPath );
        if ($to == "") $to = substr($mail->headers['Delivered-To'],2);
        // end hack

        // more code here
}


function formatAddress( $address )
{
        return $address->email;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

So if I use the following, I should be ok.

function formatAddress( $address )
{
        if($address instance of ezcMailAddress)
        {
                return $address->email;
        }
}



I also have some USERS (not spam) that are sending messaged from phones where the FROM header is blank but reply-to is populated or sometimes the TO is not populated so I search the Delivered-To header. So I try to solve that by checking with the following:

if ($from == "" || is_null($from)) $from = formatAddress( $mail- >returnPath ); if ($to == "" || is_null($from)) $to = substr($mail- >headers['Delivered-To'],2); // this is the [EMAIL PROTECTED] address. so strip out the "1-"

I that the best way to handle that.

Thanks again guys. much appreciated. Thank you.




On Wednesday 07 November 2007 21:43:07 Dave Fischetti wrote:
Hey Gontran, Thanks for the reply.

I don't believe anything has changed. Since seeing this error. Though
I am on a Dedicated Virtual Server on Media Temple. They do
periodically update things. But my version of EZ has remained 2007.1.1

PHP 5 is running in CGI mode (I still have php 4 on the server
everywhere else. This is my only php5 script right now).

I guess I can live with the Notice, and just silence the PHP5 notices
display. I just thought I might have missed something.

The script is being called by a cron job:
/usr/bin/lynx -source http://www.domain.com/inbox.php5

I guess I could silence the cron so it doesnt reply at all (thats
where I'm seeing the errors. In my returned cron emails)

Thanks so much for the reply. Really appreciate it.

Fish

<>

On Nov 7, 2007, at 1:24 AM, Gontran Zepeda wrote:
In the interest of understanding your situation, please allow a
question or
few.

% On 2007-11-07 at 00:20:53 -0500, Dave Fischetti wrote:
I'm using the MAIL component in my application. All has been running
great, but recently started receiving this error sporadically when
parsing incoming mail in a mailbox.

<b>Notice</b>: Trying to get property of non-object in <b>/var/ www/
vhosts/domain.com/httpdocs/inbox.php5</b> on line <b>684</b><br />
Has anything changed on your system relating to web services?  Have
you
changed the version of Components that you are using?  Which version
are
you using?

That line is this function:

function formatAddress( $address )
{
   return "{$address->email}";
}

now I'm not sure what is causing it all of a sudden, but I am seeing spam that sometimes comes into the account that has now FROM address,
but I haven't ensured that its happening when receiving those
messages.


Any help would be greatly appreciated.
Honestly, this seems like a harmless error message considering the
circumstance you explain.  May I suggest modifying your php.ini
settings to
not output error level NOTICE warnings?  I believe that may cure
what ails
your system.

Yours,
--
Gontran
% # E Pluribus Unix
% /usr/bin/fortune
BOFH Excuse #254:

Interference from lunar radiation

Hi Dave,

I just feel bad about ignoring the real cause of the problem. The code snippet you sent is not enough to analyze the problem, because we don't see where and
how the $address object is created.

Instead of ignoring the notice, you could for example add sth. like:

if($address instance of ezcMailAddress)
{
   return $address->email; // Why the { and " here?
}
return '';

But you should investigate, why you actually don't give an object to the
formatAddress function.

Hi,

As Dave said earlier, there are some spam messages with no From address.
In this case the $address which is passed to the formatAddress is null.
So as Thomas said, to avoid the notice you should check if $address is
an ezcMailAddress before returning its email property.

Cheers,
Alex.

--
Alexandru Stanoi
eZ Components System Developer
eZ Systems | http://ez.no
-- 
Components mailing list
Components@lists.ez.no
http://lists.ez.no/mailman/listinfo/components

Reply via email to