How to mail store in txt file in html
You can store a mailto link in a text file and then include it in an HTML file using the <a>
tag. Here's an example:
mail.txt
mailto:[email protected]?subject=Hello&body=This%20is%20a%20test%20email
index.html
<a href="mailto:{{ mail.txt }}">Send Email</a>
In this example, the mail.txt
file contains the mailto link, and the index.html
file includes the link using the <a>
tag.
When the user clicks on the "Send Email" link, their default email client will open with the subject and body pre-filled.
You can also use JavaScript to read the contents of the mail.txt
file and include it in the HTML file. Here's an example:
<script>
const mailLink = document.createElement('a');
mailLink.href = 'mailto:';
mailLink.text = 'Send Email';
fetch('mail.txt')
.then(response => response.text())
.then(text => {
mailLink.href += text;
document.body.appendChild(mailLink);
});
</script>
This code creates a new <a>
element and sets its href
attribute to the contents of the mail.txt
file. It then appends the element to the HTML document.
Note that in both examples, you'll need to replace [email protected]
with the actual email address you want to use.