• Recent
  • Unsolved
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Register
  • Login
  • Recent
  • Unsolved
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Register
  • Login

E-mail Notification

Scheduled Pinned Locked Moved
Feature Request
7
20
8.8k
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.
  • L
    Lee Rowlett Developer
    last edited by Apr 23, 2013, 10:05 PM

    Hi Guys,

    is there anyway to get FOG to send an e-mail once an image task has started/completed? i’m sure i saw someone do this on the old forum but didn’t need the facility at the time. wondered if anyone else already has this setup? going to use it as a call logging system can automatically create calls from e-mails.

    could anyone point me in the right direction?

    P.s didn’t post it into the general support as (i believe) it’s not in FOG so it’s also a feature request… 🙂

    1 Reply Last reply Reply Quote 0
    • L
      Lee Rowlett Developer
      last edited by May 1, 2013, 2:04 PM

      anyone?? 🙂

      1 Reply Last reply Reply Quote 0
      • F
        Fernando Gietz Developer
        last edited by May 6, 2013, 1:15 PM

        I think that develope it is really easy.

        There are tree web service (they are located in WEBROOT_DIRECTORY/fog/service):

        [LIST]
        []Pre_Stage1.php . This web service is called when a task begins.
        [
        ]Post_Stage2.php . This web service is called when an upload task ends .
        [*]Post_Stage3.php . This web service is called when an download task ends .
        [/LIST]

        Those web services are called by fog script either when you upload either when you download an image. Those web services responde with an echo (##), if the proccess finishes well. You can call to the [I][B]mail[/B][/I] php function (you can see the sintaxis [URL=‘http://php.net/manual/en/function.mail.php’]here*[/URL] ) to send an email. You must call it before the echo.

        ===============================

        • [url]http://php.net/manual/en/function.mail.php[/url]
        1 Reply Last reply Reply Quote 0
        • L
          Lee Rowlett Developer
          last edited by May 24, 2013, 10:44 AM

          hi, got this working perfectly now thanks for pointing me in the right direction! 😄 the only thing i need to do in Post_Stage3.php is get the hostname to put into the mail function as Post_Stage3.php only pulls hostid and i’m having a complete mental block on how to get hostname without creating a new function or mysql connection. i know the functions there but cannot remember! lol

          1 Reply Last reply Reply Quote 0
          • F
            Fernando Gietz Developer
            last edited by May 24, 2013, 10:56 AM

            You don’t need create a new query to know the hostname. Probably, the fog script knows the hostname, it is necesary to change it when you download an image. Check the PXE file to know it.

            Then, you can change the web service call:

            [CODE]wget -q -O /tmp/co.txt “http://${web}service/Post_Stage3.php?mac=$mac&imgid=$imgid&hostname=$hostname” &>/dev/null[/CODE]

            Capture the hostname in the Post_Stage3.php file:
            [PHP]$hostname = $_GET[“hostname”];[/PHP]

            1 Reply Last reply Reply Quote 0
            • L
              Lee Rowlett Developer
              last edited by May 24, 2013, 11:01 AM

              of course!! thank you, as I say stupid mental block! lol

              1 Reply Last reply Reply Quote 0
              • L
                Lee Rowlett Developer
                last edited by May 24, 2013, 11:05 AM

                This post is deleted!
                1 Reply Last reply Reply Quote 0
                • L
                  Lee Rowlett Developer
                  last edited by May 24, 2013, 12:10 PM

                  this didn’t work 😞 hostname is blank

                  1 Reply Last reply Reply Quote 0
                  • L
                    Lee Rowlett Developer
                    last edited by May 24, 2013, 12:12 PM

                    want to try and avoid writing a new query but unless you got any other idea?.. thanks for the help btw

                    1 Reply Last reply Reply Quote 0
                    • F
                      Fernando Gietz Developer
                      last edited by May 24, 2013, 12:38 PM

                      [quote=“Lee Rowlett, post: 12364, member: 28”]this didn’t work 😞 hostname is blank[/quote]

                      What is the reason to be blank? The PXE file hasn’t the hostname, the fog script not get the $hostname or the $_GET variable is empty?

                      1 Reply Last reply Reply Quote 0
                      • L
                        Lee Rowlett Developer
                        last edited by May 24, 2013, 1:05 PM

                        The PXE file hasn’t the hostname

                        1 Reply Last reply Reply Quote 0
                        • F
                          Fernando Gietz Developer
                          last edited by May 24, 2013, 2:04 PM

                          There is the problem 🙂 You can solve it easily.

                          When you create a task, the webUI calls to tasks.confirm.include.php ( you can locete it in WEBROOT_DIRECTORY/fog/management/includes/ ). This php file creates the PXE file depending the tasks type. For example, to create a multicast download task, the tasks.confirm.include.php calls to :

                          [PHP]$taskid = createImagePackageMulticast($conn, $imageMembers[$i], $taskName, $port, $tmp, (!empty($_GET[“debug”]) && $_GET[“debug”] == “true” ), true, $shutdown, $imageMembers[$i]->getKernel(), $other , (empty($bashscript)? “”:$bashscript), $type, $taskPCT);[/PHP]

                          This function uses the [B][I]$other[/I][/B] variable to setup the hostname, check if this variable has setup the hostname.

                          1 Reply Last reply Reply Quote 0
                          • X
                            x23piracy
                            last edited by May 26, 2013, 12:14 PM

                            Hi,

                            nice thread very interesting, @Lee do you have it working now?
                            Can you post a little overview of what u’ve done please?

                            Greetz X23

                            ║▌║█║▌│║▌║▌█

                            1 Reply Last reply Reply Quote 0
                            • F
                              falko Moderator
                              last edited by May 26, 2013, 12:23 PM

                              [quote=“x23piracy, post: 12383, member: 3982”]Hi,

                              nice thread very interesting, @Lee do you have it working now?
                              Can you post a little overview of what u’ve done please?

                              Greetz X23[/quote]

                              yes this would be very useful if you could share an overview, maybe if you could post it in the tutorial section?

                              1 Reply Last reply Reply Quote 0
                              • L
                                Lee Rowlett Developer
                                last edited by May 28, 2013, 7:15 AM

                                Hi,

                                i have got it working but had to write a seperate query to get hostname. it is hard to write a step by step as you can customize it to however you want and use any mail protocol, i am using sendmail/mailutils - below is what i did.

                                edit the file …/fog/service/Post_Stage3.php

                                just before line: echo “##”; write you’re mail function i.e.

                                if ( checkOut( $conn, $jobid ) )
                                {
                                [B]mail(“emailaddress@tosendto”,“$hostname - Image Task Completed”, “$hostname has been successfully imaged”);[/B]
                                echo “##”;

                                // Now update the imaging log.
                                @logImageTask( $conn, “e”, $hostid );

                                if you would like to get the hostname in the email - you have to include this, it is another query and there may be a cleaner way to do this but for now put this anywhere before the if statement put…

                                $hst = “SELECT hostName FROM hosts WHERE hostID like '”.$hostid.“'”;
                                $res1 = mysql_query( $hst, $conn ) or die( mysql_error() );
                                $ar1 = mysql_fetch_object($res1);
                                $hostname = $ar1->hostName;

                                optional:
                                on the server install sendmail/mailutils
                                apt-get install sendmail
                                apt-get install mailutils

                                recommend stopping sendmail running a daemon.

                                hope this helps

                                …thanks for the guidance Fernando

                                1 Reply Last reply Reply Quote 0
                                • X
                                  x23piracy
                                  last edited by May 28, 2013, 12:15 PM

                                  Hi,

                                  @Lee thank you for sharing this information i will try this out and report back.

                                  Greetz X23

                                  ║▌║█║▌│║▌║▌█

                                  1 Reply Last reply Reply Quote 0
                                  • R
                                    raymondub
                                    last edited by Feb 17, 2015, 4:11 PM

                                    Hi,
                                    something about this ? Is it in the last version of fog ?
                                    thx

                                    1 Reply Last reply Reply Quote 0
                                    • Tom ElliottT
                                      Tom Elliott
                                      last edited by Mar 10, 2015, 5:11 PM

                                      It’s added.

                                      Please help us build the FOG community with everyone involved. It's not just about coding - way more we need people to test things, update documentation and most importantly work on uniting the community of people enjoying and working on FOG! Get in contact with me (chat bubble in the top right corner) if you want to join in.

                                      Web GUI issue? Please check apache error (debian/ubuntu: /var/log/apache2/error.log, centos/fedora/rhel: /var/log/httpd/error_log) and php-fpm log (/var/log/php*-fpm.log)

                                      Please support FOG if you like it: https://wiki.fogproject.org/wiki/index.php/Support_FOG

                                      1 Reply Last reply Reply Quote 0
                                      • R
                                        raymondub
                                        last edited by Mar 23, 2015, 9:07 AM

                                        hi,
                                        I was searching for that option and I realised that I was not in the same last version… I was in the 1.2.0 and not in the svn version. I m now in 1.2.0 version 3118 and I see a section “Fog Email Settings”. I think it s that but how does it work ?
                                        The package has been installed but i m not receiving mails…
                                        apt-get install sendmail
                                        apt-get install mailutils

                                        thx

                                        1 Reply Last reply Reply Quote 0
                                        • S
                                          Sebastian Roth Moderator
                                          last edited by Mar 23, 2015, 9:36 AM

                                          Do you see any errors in your apache log files when mail is being sent? I guess you need to configure smart host with sendmail… [url]https://www.dnsexit.com/support/mailrelay/sendmail.html[/url]

                                          Web GUI issue? Please check apache error (debian/ubuntu: /var/log/apache2/error.log, centos/fedora/rhel: /var/log/httpd/error_log) and php-fpm log (/var/log/php*-fpm.log)

                                          Please support FOG if you like it: https://wiki.fogproject.org/wiki/index.php/Support_FOG

                                          1 Reply Last reply Reply Quote 0
                                          • 1 / 1
                                          • First post
                                            Last post

                                          174

                                          Online

                                          12.0k

                                          Users

                                          17.3k

                                          Topics

                                          155.2k

                                          Posts
                                          Copyright © 2012-2024 FOG Project