Jump to content

Getting email from a processwire form (solved)


ryanC
 Share

Recommended Posts

@ryanC - I don't know what that wireMail() isn't working. I just copied the code from @szabesz's post and with the Mail Interceptor panel enabled, it returned the same result that he had - a successful mail. Just curious - did the AJAX bar appear below the main Tracy debug bar? Assuming you installed a recent version of Tracy your screenshot is showing the main Mail Interceptor panel, not the one updated by Console mail call. Actually it looks like @szabesz has an old version also. See my screenshot showing the AJAX version with (ajax) in the header:

59f0ea7873155_ScreenShot2017-10-25at12_47_53PM.png.7844a50286c608a354f5a0aae779a28e.png

  • Like 1
Link to comment
Share on other sites

2 minutes ago, ryanC said:

Hi Adrian, no AJAX bar, so far I've only seen the green mail interceptor panel.

I'm attaching a screenshot of what I have now:

 

 

 

interceptor3.jpg

Ok, it looks like you have seeing a bug there that is causing problems with the AJAX bar - we need to solve that and then hopefully you should be good. Can you please send a screenshot of the error when you hover over the SnippetRunner panel please? And also those from the "2 errors" panel.

Also, can you please let me know what version of Tracy you are running?

Link to comment
Share on other sites

Ah - thank you. You must be using an older version of PW before there was support for $urls. My fault - I should have used the older and more compatible $config->urls. I'll post a fix shortly, but in the meantime, I think if you just disable the SnippetRunner panel, everything should work ok.

Link to comment
Share on other sites

Ok, it looks like your AJAX panel might not be working. Are you running PHP 5.3? If so, the AJAX panel won't work. If you are running 5.4 or greater, please check "backend" in the "Show Debug Bar" section and load the main admin page tree view and let us know if the AJAX panel shows up there.

Link to comment
Share on other sites

Something new happened though when I hit "run" for the email test. The console has a bunch of code there now, I didn't see that before. 

Actually I guess that's the default behavior for the Page view, earlier I was on the module page itself.

Link to comment
Share on other sites

6 minutes ago, ryanC said:

The console has a bunch of code there now, I didn't see that before. 

Sorry, I don't know what you mean - can you post a screenshot and explain please?

I think you definitely have some AJAX issues, but I have no idea what at the moment. Any chance this site is live somewhere I could take a look?

Not that it should matter, but do you have the core SessionHandlerDB module installed?

Also, what happens if you reload the page after submitting the console mail code - does the Mail panel show up populated then?

Or, what about putting that code in a template file and loading a page with the template - does the main Mail panel show then?

Link to comment
Share on other sites

Just now, ryanC said:

Bingo:

Ok, great to see that working, although I am still not sure why it didn't work on the Frontend, or has that solved itself also?

But back to the original topic - this result shows that your email is successfully being prepared and sent by PW - now it's just a matter of why it isn't actually going out. I admit I didn't properly read the early posts, but if you are using WireMailSMTP, did you use the TEST option there to test your settings?

 

Link to comment
Share on other sites

10 minutes ago, adrian said:

Sorry, I don't know what you mean - can you post a screenshot and explain please?

I think you definitely have some AJAX issues, but I have no idea what at the moment. Any chance this site is live somewhere I could take a look?

Not that it should matter, but do you have the core SessionHandlerDB module installed?

Also, what happens if you reload the page after submitting the console mail code - does the Mail panel show up populated then?

Or, what about putting that code in a template file and loading a page with the template - does the main Mail panel show then?

Ok... looks like we were successful here. I didn't submit but now we are up to date. Site is not live yet, and I don't have SessionHandlerDB installed.

 

Link to comment
Share on other sites

1 minute ago, adrian said:

Ok, great to see that working, although I am still not sure why it didn't work on the Frontend, or has that solved itself also?

But back to the original topic - this result shows that your email is successfully being prepared and sent by PW - now it's just a matter of why it isn't actually going out. I admit I didn't properly read the early posts, but if you are using WireMailSMTP, did you use the TEST option there to test your settings?

 

It is on Front End now, so everything you did with the update was successful.

I do have WireMailSMTP installed, and after entering Gmail settings it said it the settings were correct. Let me open up the module..

Link to comment
Share on other sites

WireMail SMTP, I have entires for:

localhost, SMTP hostname, SMTP Port, SMTP user, SMTP password, Use SSL, SMTP Certificate...

 

I'm assuming Sender Email Address is my own? That is in there also... so with those settings I get "Success! SMTP Settings appear to work correctly"

Link to comment
Share on other sites

1 minute ago, ryanC said:

WireMail SMTP, I have entires for:

localhost, SMTP hostname, SMTP Port, SMTP user, SMTP password, Use SSL, SMTP Certificate...

 

I'm assuming Sender Email Address is my own? That is in there also... so with those settings I get "Success! SMTP Settings appear to work correctly"

Ok, so that sounds promising. What happens if you run that Console panel code without the Mail Interceptor activated. Does the email get sent?

  • Like 1
Link to comment
Share on other sites

sure, this is for the results page:

<?php
$email = filter_input(INPUT_POST, 'email', FILTER_VALIDATE_EMAIL);

 
if (isset($_POST['submit'])) {
    $to = 'me@email.com';
    $subject = 'Feedback from my site';
    $message = 'Name: ' . $_POST['name'] . "\r\n\r\n";
    $message .='Email: ' . $_POST['email'] . "\r\n\r\n";
    $message .='Comments: ' .$_POST['comments'];
     
     
    $mail = wireMail();
    $mail->to($to)->from('me@email.com'); // all calls can be chained
    $mail->subject($subject); 
    $mail->body($message);
    $mail->send(); 
}
?>

form page: 

    <div class="formWrap">
    <h1>Simple Email Form 1</h1>
    <p><em>Most basic form possible to get email response in processwire</em></p>
 
    <form id="simpleForm1" action="http://localhost:8888/signage-B/form-response-1" method="post" target="_blank">
 
        <label for="name">Name:</label>
        <input type="text" name="name" id="name">
        
        <label for="email">Email:</label>
        <input type="email" name="email" id="email"><br /><br />
        
        <label for="comments">Comments:</label>
        <textarea name="comments" id="comments"></textarea>
     
    <div class="submission-test">
        <input type="submit" name="send" value="Submit">
    </div>
    </form>
    </div>

 

Link to comment
Share on other sites

I think the most likely thing is that nothing is getting processed. You are checking for:

if (isset($_POST['submit'])) {

but you don't have a field named "submit" - take a look at the Request Info panel in Tracy under Input POST and you'll see an entry for "send", but not submit.

You can also add a

bd('test');

call as the first line inside the isset and you'll see that nothing will show up in the Dumps Recorder panel in Tracy, because nothing in there is being processed.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...