Sending form data via PHPMailer – How to action PHP script from a form

You are actually closer in your first attempt.

My recommendation would be to create a folder called “scripts” in the WP root and put your PHP script files in here as well as your attachment(s). You will then need to declare the full path in your action attribute as the script does not now share the same file path as in your “flat HTML file structure”.

Your action code will then be action="http://damtech.it/demo/etap/scripts/phpmailersub.php"

Easy as that. No need to create a plugin at all (although this may be better practice). Don’t forget to change the details within phpmailersub.php to accommodate the changes made in terms of attachment paths (server path), page directs etc.

Leave a Comment