Skip to content

tri-bit/webflow-mailgun-php

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Webflow Mailgun Php

Deliver seperate forms on your Webflow site to different emails using a simple php endpoint.

The form submission will still be recorded on Webflow's form backend and sent (If an email address is specified in Webflow's form settings page.)

Installation

  1. Copy the webflow/webflow-script.js contents to the Footer Code section of your site's custom code page (in the webflow designer.)
  2. Upload the php code into a new live folder on a standard php hosting service. Make sure to include the index.php to hide your directory contents which contains sensitive data

Setup - Webflow

  1. Update the webflow script's _mailgunRelayEndpoint var to point to the live location of your mailgun-relay.php file.
var _mailgunRelayEndpoint = 'https://*yourendpointurl*/mailgun_relay.php';
  1. Every form you wish to be relayed will need to add a custom div attribute of data-relay="true" added inside of the webflow form settings (see image below.)

  2. Check and confirm you have a unique form name assigned to every Webflow form you want to relay ("Support" in the example below.) Also note the Relay attribute has been correctly added:

alt text

Setup - Php Server

  1. Update everything inside of asterisks (*) in the settings.php file.
  2. Update the relay destination array which maps the Webflow form names (Case Sensitive) to destination email addresses:
$relay_destinations = array(
        "Form Name 1" => ['[email protected]'],
        "Form Name 2" => ['[email protected]', '[email protected]'],
);

Testing your Form Setup

By setting $debug_destination_mode = true; (inside settings.php) the form will not be sent on submission but will return the email destinations it would have gone to allowing you to confirm settings before going live. (Message will be viewable in the browser console.)

Logging

The default setting $relay_logging = true; (inside settings.php) will record relay usage in a logs folder. (But not emails addresses or email content.)

Example logs:

Sunday, 10-May-20 22:03:47 UTC | error - destination not found for formSupport2
Sunday, 10-May-20 22:17:32 UTC | Quotes / Sales >  mailgun response: Queued. Thank you.

Notice - Recaptcha is not re-validated by the server

Recaptcha tokens can only be validated once and Webflow validates the token on the browser so there is currently no re-validation on the php server side. (So theoretically someone could get around recaptcha and use the relay code to spam the emails specified in $relay_destinations )

About

Send seperate webflow forms to different emails addresses via mailgun

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published