6 Replies Latest reply on Jul 20, 2017 7:39 AM by vaios_p

    Problem with running script via PHP

    vaios_p

      Hello everyone,

       

      I have a problem with running a Send Mail Script Step via PHP.

       

      This is the php code

       

      $layout = 'My Layout';

      $script = 'Send Mail';

      $parameter = '';

      $request = $fm->newPerformScriptCommand($layout, $script, $parameter);

      $result = $request->execute();

       

      if (FileMaker::isError($result))

      {

      $message .= 'The email address you entered does not exist' . '<p>';

      }

      else

      {

      $message .= 'Your password will be sent to your email address shortly.' . '<p>';

      }

       

      And this is the FileMaker Script.

       

      Allow User Abort [ On ]

      Set Error Capture [ On ]

      Send Mail [ Send via SMTP Server ; No dialog ; To: "receiver@mail.com" ; Subject: "New Order of Services" ; Message: "Order received" ]

       

      Go to Layout [ “My layout”]

      New Record/Request

       

      Now my problem is that when i run the script via PHP the mail is not sent (but i know the script has been executed because it creates a new record)

       

      And i know the SMTP server is set up properly because when i execute the same script using FileMaker 15 is works perfectly , sending the mail i want.

       

      Do you have any ideas on what might be the problem?

        • 1. Re: Problem with running script via PHP
          Jens Teich

          If you set error_capture ON, you will miss error messages if you don't ask for them.  After mail step there should be something like:

           

          Set Field [ result; Get ( LastError )]

          1 of 1 people found this helpful
          • 2. Re: Problem with running script via PHP
            Jens Teich

            And there might be a layout focus problem.

            You first send the mail and then change layout.  Which is the original layout?  Does it allow email step to get required information?

            • 3. Re: Problem with running script via PHP
              vaios_p

              Thank you for your response,

               

              At the moment I am trying to just send an email, I do not have any data posted with the email.

               

              It is from an online application where  the user fills out a form , the data is posted back to FileMaker (and it is editing the correspodent fields correcty so far) and then i want an e-mail to be sent to inform my cilent that he has received a new online application.

               

              I have very little experience with FileMaker , if i add the Set Field [ result; Get ( LastError )] step that you mentioned, do you think i might be able to identify any problems by accesing the FileMaker server log ?

              • 4. Re: Problem with running script via PHP
                vaios_p

                With your help i have modified the script to look like this

                 

                Allow User Abort [ On ]

                Set Error Capture [ On ]

                Send Mail [ Send via SMTP Server ; No dialog ; To: "receiver@mail.com" ; Subject: "New Order of Services Received" ; Message: "Order of services received through Online Form Submission" ]

                Set Variable [ $error ; Value: Get (LastError) ]

                Go to Layout [ “Errors” (Errors) ]

                Set Field [ Errors::Error ; $error ]

                 

                 

                Now i have the error code , it is 1502 The connection was refused by the SMTP server.

                 

                I also checked that I have the same error when I choose to perform script on server.

                 

                 

                I believe it is safe to assume that the problem is not with the php, but most likely with SMTP settings of the FMS.

                 

                 

                Thanks again for your help.

                 

                • 5. Re: Problem with running script via PHP
                  beverly

                  Could this be related to:

                  FMS 16 breaks CWP

                  Beverly

                  • 6. Re: Problem with running script via PHP
                    vaios_p

                    I would like to thank both you and user4078 for you time and help.

                     

                    The problem was with the SMTP server settings , after changing that , the script now works like a charm.