How to create a text that permit to send email in HTML document when button is clicked ?
In this article, we will learn How to create the text that permits sending the email in the HTML document when the button is clicked. We can simply create a form that can be used for creating the text i.e body of the message as well as it can be used for sending the email to the respective address.
The action property of the form is used to specify the URL of the document where the data is to be sent after submission of the form with the help of a button. In the action property, we can define the email of the sender using the mailto link in the form of HTML. Also, we can configure the email using some other properties in the mailto link.
<form method="POST" action="mailto: email@example.com" enctype="multipart/form-data">
We can also send mail in the following ways:
Cc field: Cc stands for Carbon Copy. The user whose e-mail address is specified in this field will get a copy of the e-mail message. In this way, you can send a similar message to multiple users with one click. The e-mail addresses to whom the e-mail was sent will be visible to all other recipients as well. It is an optional field. You can use this field depending on your requirement.
<form action="mailto:firstname.lastname@example.org ? Ccemail@example.com"> Send Email </form>
Bcc field:: Bcc stands for Blind Carbon Copy. The user whose e-mail address is specified in this field will get a copy of the e-mail message but the recipient’s e-mail address mentioned here will not be visible to other recipients. It is an optional field. You can use this field depending on your requirement.
<form action="mailto:firstname.lastname@example.org ? Bccemail@example.com"> Send Email </form>
Let’s understand how to create a text that permits to send the email when the button is clicked using an example.
Example: Creating a button for sending an email using the action attribute of the form.