Php program problem

bickford

Getting comfortable
Mar 12, 2016
468
432
Hello everyone

I am trying to use a php program on my Nas to control a HIKVISION camera.

I have an Optex BX80NR (passive infrared ) i would like the BX80NR send a command to the HIK to receive a picture by mail.

BX is connected to axis P8221 to have the I/O converted to HTTP command.

Here is my php script .
 
Last edited:
are the images being written to to that path?
 
email too large? might try attaching just a single file first?
 
  • Like
Reactions: hmjgriffon
email too large? might try attaching just a single file first?
if e-mail was too large I guess it would have been refused by the SMTP server and not accepting "only" text (well, I never saw any server doing such filtering not telling it do not exist), except if it is the class helper that have some limitation.

@bickford can you sniff your network and see what is really sent to the smtp server ?

Is it this class PHP Attachment Mailer Class | Web Development Blog ?

In your source I see no "false" return test over process_mail() to check if any problem as showed in source but as you receive a mail anymway (whenever it's only the text part) I guess you'll get no erreor :

PHP:
function process_mail() {
        if (!$this->valid_mail_adresses) return;
        if (mail($this->mail_to, $this->mail_subject, $this->build_message(), $this->headers, "-f".$this->webmaster_email)) {
            $this->msg[] = "Your mail is succesfully submitted.";
            return true;
        } else {
            $this->msg[] = "Error while sending you mail.";
            return false;
        }
    }
 
Last edited:
  • Like
Reactions: hmjgriffon
Tryed with only 1 file ; same problem , i receive only text " Une alerte devant la maison " and thats all.
With wireshark what kind of command i have to use ? http.request ?


I have seen this error on apache log :

Warning: mail(): Multiple or malformed newlines found in additional_header in /var/www/html/attach_mailer_class.php on line 280

BICK
 
Tryed with only 1 file ; same problem , i receive only text " Une alerte devant la maison " and thats all.
With wireshark what kind of command i have to use ? http.request ?


I have seen this error on apache log :

Warning: mail(): Multiple or malformed newlines found in additional_header in /var/www/html/attach_mailer_class.php on line 280

BICK
OK so your class seems to have some issues, you could handle the attachements yourself. But what is the size of received e-mail ? I mean is it a few bytes only or is it expected size that your e-mail software cannot fully decode so it show you only text part ?
 
the size of the jpeg file i am trying to send is 272 Ko ...

BICK
question is do you receive a mail containing this malformed attachement or is the picture trucated/removed directly by php mail() before sending the email ?
 
I only receive the text , picture is not sended at all i think

BICK
Sorry but "facts" are more usefull that "I think but I am not sure may be may be not depend the direction of the wind" ;-)

So to be sure open the source of the received e-mail if your email client software allow it (or may be it can show some properties with its size), , or do some tcpdump from your server to sniff outgoing SMTP flow, or send an other e-mail and POP3 manually the account to check the size of it :

telnet my.pop.server 110
user xxx
pass yyy
list
 
Wouldn't an error about new lines found mean a problem with syntax.

Sent from my Nexus 6P using Tapatalk
If we talk about its code, it is wrong from the beginning as he uses HTML tags inside a normal email without specifying the email is html so some headers are missing like :

MIME-Version: 1.0
Content-type: text/html; charset=iso-8859-1

and not exactly as it attaches also binaries so it would be

Content-Type: Multipart/Mixed;

But I have not spent time to read all its email class helper to check how it handle those attachements.
 
Last edited:
  • Like
Reactions: hmjgriffon