Jump to content

[SOLVED] How to use WireMail with a submit button?


louisstephens
 Share

Recommended Posts

I have been using the wiresmtpmail module in a few installs for sending out automated emails etc etc, and it works flawlessly. However, I now need to send an email when a user submits a form, and for the life of me I can not figure out how to get the form to submit.

	if(isset($_POST['Submit'])) {
	$mail = wireMail(); // calling an empty wireMail() returns a wireMail object

	$toName = $sanitizer->text($input->post->fullname);
	$toEmail = $sanitizer->email($input->post->email);
	$phone = $sanitizer->text($input->post->phone);
	$comments = $sanitizer->text($input->post->comments);
	$subject = $page->store_name . $page->title;
	$numSent = wireMail($toName, '', $subject, $textBody, $options); 
}

If I remove the if statement, the form submits just fine, however you can just refresh the page (without adding anything to the fields), and it will submit a blank email every refresh. Has anyone gotten this working with a submit button?

Link to comment
Share on other sites

5 minutes ago, louisstephens said:

Has anyone gotten this working with a submit button?

Of course :)

Is the name of your submit button actually set to "Submit"? 

Have you check the Request Info panel in Tracy to see if there is in fact a "Submit" parameter in the POST data?

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

×
×
  • Create New...