How to create action in dreamweaver for mail
In Dreamweaver, you can create an action to send an email using the "Send Mail" action. Here's a step-by-step guide:
Prerequisites:
- Make sure you have a form in your HTML file that collects the necessary information (e.g., name, email, message).
- Create a new JavaScript file or open an existing one.
Step 1: Create a new JavaScript file
- In Dreamweaver, go to File > New > JavaScript.
- Name your file (e.g., "sendmail.js") and save it in the same directory as your HTML file.
Step 2: Write the JavaScript code
- In the JavaScript file, add the following code:
function sendMail() { var name = document.getElementById("name").value; var email = document.getElementById("email").value; var message = document.getElementById("message").value;
var mailTo = "[email protected]"; // Replace with your email address var subject = "Contact Form Submission"; var body = "Name: " + name + "\r\nEmail: " + email + "\r\nMessage: " + message;
var mail = document.createElement("a"); mail.href = "mailto:" + mailTo + "?subject=" + subject + "&body=" + body; mail.click(); }
Replace `[email protected]` with your actual email address.
**Step 3: Add the JavaScript file to your HTML file**
1. In your HTML file, add a `<script>` tag to link to your JavaScript file:
```html
<script type="text/javascript" src="sendmail.js"></script>
Step 4: Add a form button to trigger the action
-
In your HTML file, add a form button that will trigger the
sendMail()
function:<form> <!-- Your form fields here --> <input type="button" value="Send Email" onclick="sendMail()"> </form>
Step 5: Test the action
-
Save both files (HTML and JavaScript).
-
Open your HTML file in a web browser.
-
Fill out the form fields and click the "Send Email" button.
-
The email should be sent to the specified email address.
That's it! You've created an action in Dreamweaver to send an email using JavaScript.