Netgate Discussion Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Search
    • Register
    • Login

    PHP Mail Function on Custom Squid Error Page

    Scheduled Pinned Locked Moved pfSense Packages
    8 Posts 5 Posters 4.3k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • S Offline
      SpankIt
      last edited by

      I've successfully created a custom error page for squidguard when a website is blocked by the content filter. I would like to add a button on the page that will allow the client to contact me in order to alert me of websites that should not be blocked. In reading up on this functionality in php it has come to my attention that I will require a mail program installed on the firewall along with some configuration changes to be done to the php.ini (ref: http://www.w3schools.com/PHP/php_ref_mail.asp) file to allow this to be done.

      Is this possible without installing anything?
      If not, What email software do you suggest?

      Any help in the configuration of such a feature is greatly appreciated.

      Thank you!

      1 Reply Last reply Reply Quote 0
      • M Offline
        matrix200
        last edited by

        That depends on whether or not you want to be able to use firewall host as smtp server.
        From what your link says , all you need is smtp server accessible from the machine where the script resides.
        Most likely you will need smtp server that allows relaying if you want to send users on various domains.
        I am not 100% sure whether php included within pfsense supports that (just try to write a simple php script using mail function).

        Current network "hardware" :
        Running 2.2RC in Virtualbox 4.2.16.

        Retired:
        ALIX2C2 , 4 gigabyte disk cf card running 2.0 (official release).

        1 Reply Last reply Reply Quote 0
        • S Offline
          SpankIt
          last edited by

          Thanks for the quick reply. If I understand your post correctly I can use my ISP's SMTP server for this? (the company I work for is also the ISP). If that's the case then I just add the following line to my php.ini file and I'm good to go?

          
          SMTP=smtpservename
          
          

          EDIT: Forgot to mention in my original post. The custom redirect page is being hosted on my pfSense box. According to that page the SMTP setting seems to only be available for a windows machine. Unless they are talking about the client side.

          1 Reply Last reply Reply Quote 0
          • M Offline
            matrix200
            last edited by

            I think you have to set that in php.ini
            I believe you can use smtp server address for *nix systems too.

            Current network "hardware" :
            Running 2.2RC in Virtualbox 4.2.16.

            Retired:
            ALIX2C2 , 4 gigabyte disk cf card running 2.0 (official release).

            1 Reply Last reply Reply Quote 0
            • M Offline
              mhab12
              last edited by

              If you get this to 100% functional, please post a 'how-to' for the group.  I (and I'm sure others) would love to add this to my 'error' pages as well.  Great idea.

              1 Reply Last reply Reply Quote 0
              • D Offline
                Dipstah
                last edited by

                not sure if this helps But this is what I did to add a mailto: link to my custom block page.

                php code found in these forums

                $page = $_GET['page'];
                $group = $_GET['group'];

                /* echo "URL: $page";  
                echo "Group: $group";
                */

                ?>

                Link for email

                If you feel this site has been rated incorrectly, please "<"a href="mailto:emailaddress@dot.net?subject=Blocked Site &body=This site was blocked and was found in group . "">"click here to submit this link for review.

                SquidGuard config
                Redirect Mode = "ext url redirect (enter URL)"
                URL you need to add to squidguard config http://ip of pfsense/path to custom page..php?group=%t&page=%u

                this doesn't use php's internal mail functions but works for me. When clicked on it opens the users mail program with the subject and body already populated with info.

                1 Reply Last reply Reply Quote 0
                • M Offline
                  matrix200
                  last edited by

                  Ok there is a better option .
                  Get yourself a php mailer.
                  http://sourceforge.net/projects/phpmailer/files/phpmailer%20for%20php4/

                  Extract two php files into /etc/inc or any other folder in the include path and use their example :)
                  Doesn't support smtp auth so won't work with all servers.

                  Current network "hardware" :
                  Running 2.2RC in Virtualbox 4.2.16.

                  Retired:
                  ALIX2C2 , 4 gigabyte disk cf card running 2.0 (official release).

                  1 Reply Last reply Reply Quote 0
                  • jimpJ Offline
                    jimp Rebel Alliance Developer Netgate
                    last edited by

                    2.0 has smtp notifications built in, you might look back at the commit logs and see what was done to make that work.

                    Remember: Upvote with the 👍 button for any user/post you find to be helpful, informative, or deserving of recognition!

                    Need help fast? Netgate Global Support!

                    Do not Chat/PM for help!

                    1 Reply Last reply Reply Quote 0
                    • First post
                      Last post
                    Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.