Jump to content
CarlosEduardo2409

Do not send the email

Recommended Posts

Hello everyone, so I'm trying to make a module for the pilots to send suggestions of routes. But when I click to send it it does not send the email.

 

My core/templates/routesubmit_mainform.php - MY BUTTON CODE

<input type="submit" class="btn btn-primary btn-block btn-flat" name="submit" value='Submit Route'>

 

My core/modules/RouteSubmit.php - MY SENDEMAIL CODE

<?php

    class RouteSubmit extends CodonModule
    {
        public function index()
        {
            require_once CORE_LIB_PATH.'/recaptcha/recaptchalib.php';
            $this->set('title', 'Add Schedule');


            $this->set('allairlines', OperationsData::GetAllAirlines());
            $this->set('allaircraft', OperationsData::GetAllAircraft());
            $this->set('allairports', OperationsData::GetAllAirports());
            //$this->set('airport_json_list', OperationsData::getAllAirportsJSON());
            $this->set('flighttypes', Config::Get('FLIGHT_TYPES'));
            
            if(isset($_POST['submit'])) {
			$this->SendEmail();
		    } else {
		    $this->ShowForm();
		    }

            $this->render('routesubmit/routesubmit_mainform');
            
        }
        
        protected function ShowForm()
	    {
                //Google reCaptcha
                //updated to Google noCaptcha 1/15
                $this->set('sitekey', "MyCaptchaKey");
                $this->set('lang', 'pt');
                
	    }
	    
        
        public function SendEmail()
        {
            $name = $_POST['name'];
            $email = $_POST['email'];
            $depp = $_POST['depp'];
            $arr = $_POST['arr'];
            $route = $_POST['route'];
            $aircraft = $_POST['Aircraft'];
            $fl = $_POST['fl'];
            $dtime = $_POST['dtime'];
            $atime = $_POST['atime'];
            $ftime = $_POST['ftime'];
            $message = "From: $name \n 
                        Depp: $depp \n 
                        Arr: $arr \n 
                        Route: $route \n 
                        Aircraft: $aircraft \n 
                        Fl: $fl \n 
                        Dtime: $dtime \n 
                        Atime: $atime \n 
                        Ftime: $ftime \n";
                        
            $email_to = "MYEMAIL";
            $subject = "Pilot Submitted Route";
            $headers = "From: $email \r\n";
            Util::SendEmail($email_to, $subject, $message, $mailheader);
        }
		
}

 

Share this post


Link to post
Share on other sites
mischka    191

in your send_email I see: $email = $_POST['email'];

then later I see $email_to = "MYEMAIL"; which you then use to send the email

I would delete the second line and rewrite the first one to $email_to = $_POST['email']; and see where that goes.

Share this post


Link to post
Share on other sites
servetas    2301

$email is the pilot's email. The pilot who is sending the route request.
$email_to is where the route request is sent to.

I do not believe that this is an issue. First of all, instead of using this:

$_POST['email']

you will have to use this:

$this->post->email

You will have to do so with all the variables in the SendEmail and index function. Also, your form should include a captcha but I can see that there is not any captcha validation in the SendEmail function. I would suggest removing it from your form or validating in on the form submit. Personally, I would suggest you to add several random echo's in your code. As soon as you run your code, you will be able to understand (based on the echo's) which part of the code run and which part of the code did not run.

Share this post


Link to post
Share on other sites

Did you mean like that?

 

        public function SendEmail()
        {
            $name = $this->post->name;
            $email_from = $this->post->email;
            $depp = $this->post->depp;
            $arr = $this->post->arr;
            $route = $this->post->route;
            $Aircraft = $this->post->Aircraft;
            $fl = $this->post->fl;
            $dtime = $this->post->dtime;
            $atime = $this->post->atime;
            $ftime = $this->post->ftime;
            $message = "From: $name \n 
                        Depp: $depp \n 
                        Arr: $arr \n 
                        Route: $route \n 
                        Aircraft: $aircraft \n 
                        Fl: $fl \n 
                        Dtime: $dtime \n 
                        Atime: $atime \n 
                        Ftime: $ftime \n";
                        
            $email = "MYEMAIL";
            $subject = "Pilot Submitted Route";
            $headers = "From: $email_from \r\n";
            Util::SendEmail($email, $subject, $message, $headers);
        }

 

If you want to see my entire code: https://github.com/carlosmfreitas2409/RouteSubmit

Edited by CarlosEduardo2409

Share this post


Link to post
Share on other sites

Can you tell me when it works? I'm trying to do everything I can to fix it, too. Thank you. If I do, I'll tell you...

 

Sorry if I wrote something wrong, because I'm using google translate. I am Brazilian
 

Edited by CarlosEduardo2409

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


×