Online Users Page


QN

Previous notifications:
4 years ago
New Blog Entry In .:A-MAN:. lists stuff!
11 years ago
Regular accepted your friend request
More..
44GuitarBoy 6 years ago
@SLEDGE

I /need/ your server-side expertise here. So I just started at the farmer's market today and made...well... $3. But in cash so that's cool.

Anyways, the guy next door uses Square, and doesn't use a receipt printer. If you saw one of my earlier posts, you'll see that even though my Chromebook has a nice, big screen for Square, it doesn't communicate with external devices. I can send receipts through Square via email though. I already tested it and an ugly page with a faded Square logo and crap comes out. No actual receipt info. I think it's because the email is HTML and HP ePrint can't interpret it.

I was wondering if there was a way to use my own email address (ex. receipts@xbit.technology) and intercept incoming mail (the Square receipt) and use PHP to convert it into an image/PDF, then forward the finalized receipt to my printer. Is this possible? If it is and you can give me some links explaining me how to do this, I can save over $200 by returning the LAN printer I recently bought...Please and thanks. <3
Back

Please Login To Post

62umer936
6 years ago
@GuitarBoy
That's pretty cool.
Reply
45SLEDGE
6 years ago
And no problem!
Reply
45SLEDGE
6 years ago
Are 100% sure that is the correct path to the file? Maybe you could try putting it inside the /public_html/ directory temporarily just to see what happens.
Reply
44GuitarBoy 6 years ago
@SLEDGE Thanks for telling me how to do this by the way. Sorry I've not gotten back to you on this, but I just recently had a chance to try it out a few days ago. Here's a screenshot of what happens:

The file does exist though... So I'm not sure why it's doing this. No big deal though I think, considering people still haven't been asking for receipts. ^_^
Reply
9mjking 6 years ago
@GuitarBoy Ok then save image of the orginal receipt before converting it in another file.
Reply
45SLEDGE
6 years ago
Also make sure your parser file isn't in /public_html/ so nobody can mess with it.
Reply
45SLEDGE
6 years ago
Here are the first lines of my script:

#!/usr/bin/php -q
<?php  
// read email from stdin
 $fd = fopen("php://stdin", "r");  
 $email = "";  
 while (!feof($fd)) {  
    $email .= fread($fd, 1024);  
 }
 fclose($fd); 


Sets it to $email. I didn't give you that bit cause I figured one of the newer parser libraries would probably do it for you.
Reply
44GuitarBoy 6 years ago
@SLEDGE You're a genius.

But how do I access the email contents from the script itself? Is there a variable name?
Reply
45SLEDGE
6 years ago
And like that notice says in the screenshot, make sure to use a hashbang. Basically just put "#!/usr/bin/php -q" at the top of your file before your <?php
Reply
45SLEDGE
6 years ago
Set up the email on your host, then go to "Forwarders." Use the "Advanced Options" and point to a PHP script.


It looks like there are a lot more resources for parsing emails with PHP than there were when I did it a few years ago so I'd look into those and get back to me if you have an issue. I had to frankenstein a bunch of parsers together to get mine to work so it isn't pretty. The hardest thing about it is different senders sending things in different ways though so since you are going to be getting a consistent format it should be pretty easy regardless.

Once you have the email content you can convert it to a PDF using the html2pdf PHP library and send it on to your printer.
Reply
62umer936
6 years ago
Seems doable. I don't specifically know how to do the PHP parts, but I know my HP printer has an option to print from email.

Basically, I have my printer set up with an email address and I can email to *hiddenaddress*@hpeprint.com and it prints. You could be able to set up an email forwarder to do the same. I don't remember how much my printer costed, but my family bought it a few years ago.
Reply
44GuitarBoy 6 years ago
Granted, I may still want to keep the receipt printer actually, considering it's the only receipt printer I found that works with Square, PayPal Here, AND Vend. Plus my cash drawer works off it too, granted I'm not taking cash right now. But if one processor drops me I can easily jump to another.

Uh. On second thought never mind. If a payment processor dropped me I could just re-order the thermal printer if I ever actually needed it again. For cash transactions I could always just open the drawer manually I suppose.
Reply
v3.2