112 Responses to PHP MySQL Email Report Generator

  1. Julian says:

    I’ve had a number of emails asking how much PHP knowledge is required to implement this. The answer is very little.

    I’m also happy to provide guidance either by email or Skype if you get stuck.

    Alternatively I will fully implement the script for you (provided you give me the SQL and target email addresses) for £30 / $50.

    • Steve says:

      I agree, very little knowledge is needed. I had it up and running in minutes. A nice added benefit for my clients, saved me from having to manually do their reports. I need more things like this!

  2. Ian says:

    Excellent script followed by excellent assistance. Very pleased, saved me hours! I FULLY recommend Julian’s work.

  3. Ryan says:

    Just Purchased the script but I have not received any emails indicating how to download it. Hmmmmm I hope to get an email soon.

    • Ryan says:

      Sorry Julian.. I was to quick to comment.. :-). It was a delay with Paypal and not Julian! :-)

      Look forward to using this tool. Thanks for you QUICK response to the original comment.



  4. Ryan says:

    So I thought i would follow up with a comment on the script.

    First off this is a steal!! Get it while you can at this price! :-)
    I implemented this last night as I need to get out a daily report that my client needed desperately and the needed every morning.. So i setup the script and followed the instructions to tee and voila the script was in my inbox and my clients inbox and 8 AM this morning. I did have a question for Julian about the cron setup but he had that answered in under 25 minutes from me asking! WOW!

    Can’t really ask for much more than that.

    Thanks Julian as you really saved my bacon with my client as I over promised and couldn’t deliver until i found your website.. The world works in strange ways sometimes!! :-)



  5. James says:

    This is actually better than I expected, Julian sent me the latest version with multiple colours and a simpler set of parameters. The script saved me a couple of days of coding.

    • Julian Young says:

      Thanks James, glad you like the latest version. Will be producing some PDF documentation for it soon and updating this page to reflect the revised product. Cheers!

  6. Richard says:

    I’m looking for just this thing, but want to email a CSV file attachment of the data instead of the table in the page. Is this possible?

    • Julian Young says:

      Hi Richard,

      Absolutely but not with the script as it currently stands. I’d have to extend it to match this functionality. Tell you what, buy the script and I’ll have it done by Sunday or your money back. How does that sound?

      If you are up for that then please drop me an email with some more information about how you’d like the CSV file to work.

      How many lines would your resulting output be on average? I ask because there are two ways to do this. The most compatible would be to create the CSV in memory and then attach it to an email. The quickest would be to create the CSV as a file and attach it to the email, this overcomes issues with size to some extent but it can be an issue for clients whose hosting package does not support certain functionality.

      Naturally we’d also want an option for what character to use for field termination and field enclosure.

      Finally, what is the intended target reader? Are you hoping to open it in excel or some other spreadsheet package?

      • Tom says:

        Hi Julian,

        +1 for this functionality if possible (by the way, I bought the script a month or so back and really love it!)



  7. George N says:

    Outstanding script! Very clean code…works perfectly. Going to hire out some of my php work to Julian for sure.

  8. Eric says:

    This looks fantastic. How hard would it be to get it to include multiple reports in one email?

  9. Simon Moxon says:

    Brilliant. Did exactly what I needed, took less than 10 minutes to get up and running and saved hours worth of coding. Thanks!

  10. Kishore says:

    Hi Julian,

    I have a requirement for generating daily & weekly reports from mysql database.. and has to convert the report into PDFs and to email them to different users daily & weekly..

    can this be possible with your script..


    • Julian Young says:

      Good morning Kishore,

      There is no PDF conversion at the moment, I would need to add this and attach it to the email. I would estimate up to two hours of development time. I charge £30/ph but am happy to negotiate if that is too expensive for you. Feel free to contact me if you are interested in discussing this further.

  11. Madhav says:


    Is this a standalone application or a web application..

  12. Madhav says:


    Can it schedule multiple reports at a time?

    • Julian Young says:

      Hi Madhov, yes, you need to ensure you have a website or server with access to CRON, you can then schedule reports to run whenever you like. Daily, Weekly, on a day of the week, 1st of the month, whenever :)

  13. Len says:

    Hi, I am using xampp for windows for my dev and was wondering if you know of any CRON like setup that will work with with your software, would like to give it a bash but am not sure if xampp can do cron type setups.

    Thanks in advance.

  14. Bob Axford says:

    I needed a script to send reports daily to the business owner and thought I’d have to write it all. When I found this script I was stoked – it saved me hours of work and looks and works fantastically. It took under an hour to get it setup and running the exact report I needed without a hitch,
    Thanks Julian, a great bit of work!!!

  15. Sarah says:

    Dear Julian,

    I purchased your PHP MySQL Email Report Generator about an hour and a half ago, but haven’t received my copy of the download. Could you please email it to me ASAP- I am under a bit of a time crunch on a project.


  16. Sarah says:

    It came through! It had been wrapped up in my spam folder. Thank you, Julian!

    • Julian Young says:

      That’s good to hear, thanks Sarah. Do let me know how you get on and if you have any problems don’t hesitate to contact me. I can even give you a Skype call later today if you need some immediate help implementing it.

  17. Brian says:

    Thanks so much for this simple, fast and easy to customize PHP script! And thank you for your help via Skype on the questions I had. ANYONE reading this and who needs emailed reports from their mysql database should spend the money for the files. I spent 2-3 hours looking for something like this for free and testing out other scripts but only spent 4-5 minutes on Julian’s script and had my first report in my inbox in another 5 mins!

  18. Looks like this will do the trick… just ordered the code – am waiting to receive it.

  19. Steve says:


    Great work. Makes pulling data from our servers and formatting it for end user use effortless. It certainly saved me hours of time!


  20. Ross says:

    The script is well written and quite easy to implement. Julian even helped us modify the script to do exactly what we were looking for. Very professional, friendly and an excellent ‘code ninja’ :) highly recommended! Thanks again, Julian.

  21. Mitch says:

    Thanks Julian – saved me a lot of time – nice simple way to get what’s in the database reported out to the users – great for producing friendly daily / weekly / monthly reports from database logs… I had trouble with the underlying mail subsystem, but Julian responded quickly and helped me with the issue.

  22. Julian Young says:

    The latest version of PHP may give a warning about providing a strict date definition when using a local server. I’ll be releasing an updated version for this. Please email me if you want the latest file. Basically you just need to define the time zone in the config.php – add a new line with date_default_timezone_set(‘UTC’);

    If you want to use the correct timezone you can find the appropriate string here http://nl3.php.net/manual/en/timezones.php

  23. Linda says:

    I needed a rather quick solution and have found your PHP MySQL Email Reporter very easy to use! Saved me hours of coding. Looking forward to the additional PDF attachments too. Great job, Julian!

  24. Ryan says:

    Do you have an example of how to include multiple reports (multiple sql querys) in one email?

    • Julian Young says:

      I’ve emailed Ryan back but if anyone else needs to know how to do this let me know. Essentially there are functions for generating reports and a function for sending the reports. It’s just a case of generating two reports, appending them and send the final report in a single email.

      • Ryan says:

        Absolutly amazing product. Saved me some serious time. Julian helped me with the 2 (or more) reports in one email and first time was the charm. I recommend anyone looking for something like this script to BUY THIS ONE! It’s a godsend.

      • Andy says:

        could you let me know how to include 2 query in 1 email and if possiable with a header for each report


  25. Juan Fernando says:

    I’m from Colombia and I waste maybe three, four days searching for a good solution to mailing a mysql query. I read several forums in english and spanish as well but don’t have any succed until Julian blog was find it.

    In this country, paypal have restricted access so I just call a friend ask him to make de payment (like a favor to me) and he make the payment and now I have access to julian code.

    I’m a php beginner , I mean, I’m works with legal issues but I’m understand very quickly the code functionality and it works so perfectly that I have to say: thanks julian!! thanks!

    Greetings from Medellín, Antioquia, Colombia!.

  26. Brent says:

    How hard would it be to add a conditional e-mail statement to only send the e-mail report if there is data records returned from the query? BTW….Thanks for the code. It has helped our company generate reports within 15 minutes of implementation.

    • Julian Young says:

      Hi Brent,

      Thanks for the comment, I’ve done this before so it should be no problem at all. Let me have a look tonight and I’ll ping you over the code changes you need. in hindsight it’s something I should really add as an option in the configuration file.



  27. Linda says:

    Hi Julian,

    Love this product! Stopped by to see if there was a way to generate 2 or more reports with one email, and see you have done that now too. Could you email me what you sent to Ryan? Thanks!

  28. Steve says:

    We have Julian’s SQL Reporter integrated into roughly five applications in our production facilities. These range from production scheduling to sales call logs. His script has been instrumental in getting data out to our field sales people as well as managers.
    Recently, I ran into an issue that Julian helped me with. Now I can gush about the excellent quality of support! Fast, timely and efficient!

    Thanks Julian!

  29. Some genuinely excellent posts on this site, thanks for contribution. “Always aim for achievement, and forget about success.” by Helen Hayes.

  30. David says:

    Hi Julian,

    Brilliant product, up and running within minutes.
    However I intended to purchase the commercial version.
    Is there any difference between the private one.
    If not I will fund the difference as Ii will be using my version for commercial use.
    Please advise how I should proceed or is it easier to purchase the commercial one.

    • Julian Young says:

      Thanks for the kind feedback David, I’ve refunded your original purchase so please feel freee to purchase the commercial license. The products are identical. 1.5 will be available shortly so I will send that on to you. Thanks again David.

      • David says:

        Look forward to the update.
        However is it possible via a reports page I have setup to click on one of the xxx.php links and recieve a popup to populate the $recipient1 before it executes. This would be very handy as we are often asked to provide the some reports on an addhoc basis but to different destination email address.


  31. simon myles says:

    I was hoping to be able to put two tables from two queries (or more) onto my email one above the other.
    The script really only gives me the ability to do one query and one table?

    Am I correct or is there a work around to do this somehow.


  32. simon myles says:

    Multiple reports – just read that someone else asked for this here –
    Could you please send me the example of this.
    many thanks
    Julian Young says:
    March 8, 2012 at 9:40 pm

    I’ve emailed Ryan back but if anyone else needs to know how to do this let me know. Essentially there are functions for generating reports and a function for sending the reports. It’s just a case of generating two reports, appending them and send the final report in a single email.

  33. Antony Smith says:

    Great piece of code, works an absolute treat.

    Had a few questions and support was extremely quick and effective highly recommended.

  34. Lyle Chamney says:

    Howdy Julian,

    NOTE: the contact form doesn’t seem to be working so I thought I would try here :)

    First off, what an amazing product! Your PHP MySQL Email Report Generator is fantastic and was just what I was searching for.

    However, I have run into a bit of a lurch when trying to use a more complex SELECT statement, one that uses two tables, an INNER JOIN and a few WHERE items. It works just tickity-boo in phpMyAdmin … EXACTLY what I require. But pasting the code into the report.php yields nothing when run. A simple single table SELECT works just fine, both in TEST mode and via CRON on the “live” site.

    Is this a limitation of the app or is there something else that I need to do? I’m not all that up on PHP and the like, but can follow instructions “to the tee” :)

    Any insight will be tremendously appreciated.


  35. Lyle Chamney says:

    Thanks Julian, however there won’t be any need for you to check it out because as usual, it was “finger trouble”! LOL :) Or, more to the point, not reading the instructions thoroughly! For reasons unknown, I was using single quotes for the AS descriptions! (and had an = sign that wasn’t escaped) … worked fine in phpMyAdmin, but of course, would not within PHP. Changed them to double quotes (as you show in your very well done instructions) and escaped the = sign and all is fine! Awesome! :)

  36. Velhassan says:

    I need a automatically generate report for my database in Mysql as Daily, Weekly, Monthly and Yearly. Please give me a solution.
    Thanks in advance.

    • Julian Young says:

      Hi Velhassan, with the script here the solution would be 4 reports.

      The daily report would be a query that only reports on values for today and would run every 24 hours via a cron script.

      The weekly report would be a query that only reports on values for the week and would run every 7 days via a cron script.

      and so on…

  37. Julian Young says:

    Version 1.6 is now officially released which tackles a number of small bugs. I’ll be sending a copy to all previous purchasers, many thanks to everyone that has helped test it and all the brilliant feedback received. You guys and gals make it all worth it.

  38. Todd Boppell says:

    I bought this cool little tool to use with a client’s system, and the first report I tried worked like a charm. Then I tried a really complicated report that needed a temp table and a number of queries to populate that temp table before producing results – this proved too much for the 1.6 implementation due to delimiter issues. So I converted the complex script to a stored procedure (routine), but the PHP Script could not handle the stored proc result set.

    So I contacted Julian – and within a couple days he and I were on Skype together building a stored proc for him to test with. A week later I had version 1.7 that perfectly handles the result set of either a stored proc or a normal query.

    Thanks Julian – what incredible service and support! It has been a complete pleasure working with you!

  39. Keith says:

    Thanks for the great script, I could use the code Ryan was talking about adding two reports to one email. The other thing I was looking for was being able to attach a jpg image from the database file is in a directory with the file name in the database column. Any idea how I can get that done?

    • Julian Young says:

      Hi Keith,

      Wow not sure why I didn’t see this earlier! Two combine two reports just generate two reports like so…

      $report1 = generateReport($query1, $header, $footer, $color);
      $report2 = generateReport($query2, $header, $footer, $color);

      Then add them together in the email…


      Images are not currently supported in reports sorry!

  40. Rene says:

    Thanks for the perfect script! Works like a charm. Just one question: how can I use a query with joins? Should it work with the current version, or should I create a procedure and call that? If it should be working in this version, then I guess I made a mistake in my query although it runs in HeidiSQL.

    And will it render any images in blobfields within MySQL?

    Thanks again for the perfect reporting solution!

    • Julian Young says:

      Hi Rene,

      Thanks so much! I’ll get in touch directly by email, I can help you with a procedural call to get that working although a query with joins should work, procedures are easier and tidier :)

      It will not render blobfield images currently, that is a cool idea for a future version!

      Best wishes,


  41. Diego says:

    I’m interested in a report tool for a website. Instead of send it by mail, can I redirect the reports to my web application? It is based in Javascript and php for some backend operations.


  42. Fabio says:

    Hello Julian,

    I have a pre-sales question.

    Can this script send e-mails with reports only to fix recipients or dynamically to e-mail addresses from clients it pulls from database?

    I need to send monthly sales report and results with global totals and total weight per client, per delivery address, per product category and per article.
    I’m talking about 40.000 orders per week from +/- 1600 clients and over 7000 delivery addresses.
    So we are talking about heavy reporting.

    Thanks for your feedback.



    • Julian Young says:

      Hi Fabio

      If you are able to program in PHP then this script is for you. I do not have the time at the moment to help you code this. If you are not confident with PHP then best to find another solution.

      This script gives you a function to….

      – Generate a report based on a sql query (that query can be dynamic)
      – Email the report

      So in order to do what you want you would need to create your own loop, looping through your main loop and using a dynamic query, you would generate the report and email it to an email variable also extracted within the loop.

      Feel free to try for seven days, otherwise I am happy to refund your money if not suitable.

      Best wishes,


  43. Dennis says:

    I want to send Chinese email,could the script change charset from ISO-8859-1 to utf-8?

    • Julian Young says:

      Sorry Dennis, utf8 introduced a multitude of problems and support concerns so as such I don’t support it. Please do feel free to purchase and change the characterset and if it doesn’t suit your needs then just let me know and I will happily refund.

  44. Julian,
    We have been using the script for a while and we have always gotten some sporatic behavior in the output. It looks like a buffer issue, where there seems to be a carriage return (or newline) in the middle of the code outputted. So you can imaging what it does to HTML when the newline is done in the middle of a tag or html element. It looks broken in places. The output is fine if it were not for the new lines. Sometimes we get code bits in the report html output. Have we been doing something wrong or maybe a fix that we missed?

  45. Julian, I have briefly viewed your site and really impressed with all the great comments. I know very little about MySQL other than I use it for an application database. I have a question. I would like to send out an email report to about 70-80 customers every day which shows information regarding their account. Can this many custom reports be generated, scheduled and sent out daily? Also, I would like for the emails to be in html format with my company logo, etc. I am hoping the number of customers will be much greater so I am looking for a product that I can grow with. Thanks, Joel

  46. Hi Julian,

    Just wondering when using your version with procedure calls: how can I call a procedure with parameter? I tried this: $query = ‘CALL procedure(‘parameter’)';
    But I get a syntax error: syntax error, unexpected ‘parameter’ (T_STRING) on line 31.

    Any ideas?


  47. Daniam says:

    Great script, easily configurable. Prompt support from developer.

    Thank you very much.

  48. famasa says:

    The script is really great! I had it configured in 10 minutes. Works like a charm and everyone loves the reports. Can you please send me the instructions how to email multiple reports in the same email (same question as Eric had).

    • admin says:

      Thanks Famasa,

      It’s as easy as simply adding to $results together and emailing it. For example….

      //generate two reports with whatever data you want passed in
      $report1 = generateReport($query1, $header, $footer, $color);
      $report2 = generateReport($query2, $header, $footer, $color);

      //join the two reports into one
      $finalReport = $report1.$report2;

      //send the report!

      Let me know if that helps!

  49. Daniam says:

    Thank you very much, It worked pretty well, I love the fact that is customizable, and very easy to understand how to parameterize everything.

  50. Antony Smith says:

    Hi Julian, have you updated this to use the PDO connector since mysql_connect() is now deprecated?



    • admin says:

      Thanks for the excellent question Antony, as mysql_connect() will be removed in a future PHP release this is absolutely on my release roadmap. An updated version will be issued to all clients when it becomes available.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Visit our friends!

A few highly recommended friends...