"Severity: Notice" from custom Library |
[eluser]chadwhitaker[/eluser]
Hello, I'm creating a Codeigniter Library from a PHP class I found. The class is used to obtain emails from an email server. Here is part of my Library: Code: <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); Now using this Library I'm able to grab data from an emails header like the "to", "from", or "subject" using the headers() method. But if an email doesn't have a subject... then my controller will return an error for that email: Quote:A PHP Error was encountered Is there a way to prevent this? I know this is something that doesn't happen with the Emailreader class using just PHP (without Codeigniter) Thank you!
[eluser]cideveloper[/eluser]
Can you do a Code: print_r($mail_header); so we can see the resulting array. That way we can see what is going on with $mail_header->subject Edit: Try the below code. Code: if(strtolower($sender->mailbox) != 'mailer-daemon' && strtolower($sender->mailbox) != 'postmaster')
[eluser]chadwhitaker[/eluser]
This is the output with a test email sent without a subject. Code: stdClass Object ( [date] => Tue, 11 Jan 2011 13:29:19 -0500 EDIT: So if the subject is missing from the email, the [subject] will not be created in the array.
[eluser]chadwhitaker[/eluser]
That does prevent the error, and I can see how & why. But it there a way around this? Say I wanted to add on to this Library and have all the headers available to me. I don't want an error for every part of the array that is missing, nor have to use that code for every single array? EDIT: For example.. if I wanted to pull the "CC" from an email, but every email will not be cc'd. I would have to add the same script you used, and it will bloat this script a lot. Does that make sense? |
Welcome Guest, Not a member yet? Register Sign In |