This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

roger.creasy5931
roger.creasy5931

I have the following partial. I want it to send the form data to an email address. What happens is the URL is appended with '/?', no mail is sent.

I am finding it very difficult to find help on sending email. I am gradually piecing things together. But, I cannot find a single resource for instructions.

description = "Contact Page"
==
use Illuminate\Support\FacadesMail;
use System\Models\MailTemplate;

function onInfoRequest() {
$data = ['name'=>'test from function'];
echo 'TEST';
Mail::send(backend::mail.inforequest, $data, function($message) {
$message->to('fakeEmail@fakeURL.com', 'Roger Creasy');
});
}
==
<div class="container">
<div class="row">
    <div class="col-lg-12 text-center">
        <h2 class="section-heading">Contact Us</h2>
        <h3 class="section-subheading text-muted">Complete the form below to learn more about our services.</h3>
    </div>
</div>
<div class="row">
    <div class="col-lg-12">
        <form data-request="onInfoRequest" name="sentMessage" id="contactForm" novalidate>
            <div class="row">
                <div class="col-md-6">
                    <div class="form-group">
                        <input type="text" class="form-control" placeholder="Your Name *" id="name" required data-validation-required-message="Please enter your name.">
                        <p class="help-block text-danger"></p>
                    </div>
                    <div class="form-group">
                        <input type="email" class="form-control" placeholder="Your Email *" id="email" required data-validation-required-message="Please enter your email address.">
                        <p class="help-block text-danger"></p>
                    </div>
                    <div class="form-group">
                        <input type="tel" class="form-control" placeholder="Your Phone *" id="phone" required data-validation-required-message="Please enter your phone number.">
                        <p class="help-block text-danger"></p>
                    </div>
                </div>
                <div class="col-md-6">
                    <div class="form-group">
                        <textarea class="form-control" placeholder="Your Message *" id="message" required data-validation-required-message="Please enter a message.">            </textarea>
                        <p class="help-block text-danger"></p>
                    </div>
                </div>
                <div class="clearfix"></div>
                <div class="col-lg-12 text-center">
                    <div id="success"></div>
                    <button
                       type="submit"
                       class="btn btn-xl">
                        Send Message
                    </button>

                </div>
            </div>
        </form>
    </div>
</div>
</div>
roger.creasy5931
roger.creasy5931

btw - my test echo statement doesn't run either.

Can anyone help?

roger.creasy5931
roger.creasy5931

I am still hacking away. Is there no one who can help?? I changed the PHP bit in the code section to this:

  function onInfoRequest()
    {
        $data = ['name' => 'test from function'];
        Mail::send(backend::mail . inforequest, $data, function ($message) {
            $message->to('fake@hidden.com', 'Roger Creasy');
        });
    }

I now get an alert box with "AJAX handler 'onInfoRequest' not found. Anyone??

Last updated

roger.creasy5931
roger.creasy5931

I also tried making the onInfoRequest function public. Same result....

roger.creasy5931
roger.creasy5931

PROGRESS! I am posting this in case it helps someone else.

I found that the AJAX function had to be placed in the code section of the LAYOUT instead of the page or partial. Here is the code:

   use Illuminate\Support\Facades\Mail;
   public function onInfoRequest() {
   $data = ['name' => 'test from function'];
   Mail::send('mail.inforequest', $data, function ($message) {
   $message->to('fake@hidden.com', 'Roger Creasy');

   });
}

The current problem is that I get an alert box with an empty unnamed array (I am assuming). The alert is '[]' Any ideas of what is causing this?

Last updated

1-5 of 5

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.