Send email with html form and javascript in harlowe :

0 votes
asked Sep 8 by ife (120 points)

I want to send values in a variable to email of users. I have created a form that users can write their email addresses in.

form method="post" action="">
<input type = "email" id="email_address" placeholder="Enter your email address..." required>
    <button onclick="">Send Email</button>
</form>

How can I sent the email without using mailto:. I also want to navigate to a different passage after users have entered their email address.

I will appreciate your help on this.

1 Answer

0 votes
answered Sep 8 by greyelf (27,360 points)

There are a number of potential solutions to your request depending on the exact environment you are using or have access to. 

Are you hosting your story HTML file on a web-server with a mail-server installed or have access to a mail-server?
If you do then it may be possible to use AJAX or a third-party Javascript library to send an email via that mail-server.

If you don't have access to a mail-server then your next option is to use Javascript to access a service like EmailJS.com (**) and it will send the email for you.
** This is an example not a recommendation, as I have never used that particular service provider myself.

If you don't want to use a service like the above then your third option is to use the mailto: protocol, which is flaky at the best of times because it relies on the end-user's email client & operating system being setup correctly to handle those requests.

warning: I may of missed some options as it's been a while since I needed to write code to send emails this way, and memory isn't what it used to be.

...