Can I send mail using Javascript and jquery without a server? [duplicate] - javascript

This question already has answers here:
How to send an email from JavaScript
(20 answers)
Closed 3 years ago.
I can use only javascirpt and jquery.
My customer said without server and using javascript and jquery can send email from gmail SMTP.
Gmail SMTP surpport only use javascript and jquery can send Email? and without server?
I want send email the mail template(html) in dynamic value (without Server!)
I tried this URL content.
https://github.com/dwyl/learn-to-send-email-via-google-script-html-no-server#how
But I have to send an e-mail with the entered ID.
This ID is dynamic value.

You can not send an email direct from front-end using JavaScript, Jquery or any front-end framework/library externally using server or back-end. because your credentials are open to all and there are so many factors work behind that...
An option is to let each user use his or her sociable mail server, by doing a mailto: connection, which allows you to define the header data & including a quasi-header called 'body', which sets the content you require to pass in the message body.
You can Send Using:-
There are also some parameters to add:
However, you can append parameters to email like the following:-
Here are some parameters you can pass in the mail you want to send from front-end
mailto:-add recipients,
note:- if you want to add multiple recipients then add comma-separated as mentioned in the example.
&cc= to add CC recipients,
&bcc= to add BCC recipients,
&subject= to add mail subject,
&body= to add mail body,
Example:-
<a href="mailto:sendMe1#example.com?cc=sendMecc#example.com?bcc=sendMebcc#example.com?subject=Mail-SubJect
&body=Mail-Body....">
Send Me Email from Front-end
</a>
Some customer-service providers provide you to send an email with the help of their service smtpjs, formspree, emailjs,
Google APIs, but this is not practical plus trusted.

Related

How can I email the outcome of a shopping cart?

Using HTML and JS, I have developed a website that has multiple items in different pages with an "add to cart" button. I can link these to appear in the "cart" page but I don't want customers to pay just yet, I want customers to be able to click a button and make an order that will be sent out to us and we can process the order. I have tried to use the email tag for HTML:
<a href = "mailto:delicatedesigns#gmail.com?subject = Order&body = itemsInCart
</a>
Is there a way to include the contents of my cart page as the body of that email? if not, is there a plug in that would work well to make this happen?
You can send the list to the backend and setup a mail server using SMTP and then create a mail template that can be used to send the mail through the SMTP server.
Attach the list to the template and send the mail to the destination address using the SMTP server.
If you are using Java, try using the Java Mail API. This can help you set up an SMTP Server easily

Make the mail body disabled in mailto js

I'm building a shooping site where the customer is ablee to contact the seller with emails.
I dont want to use backend so I just use Mailto.
now, I have 2 questions:
1) Can I open the client mail with disabled field?
So that he wont be able to change the "To" field (for example)?
I dont want to use "readonly" attribute because there are also fields that the user himself need to fill.
2) Can I send the mail from my code without the customer press "send"?
Thank you guys!
Can I open the client mail with disabled field?
No.
Can I send the mail from my code without the customer press "send"?
No.
If you want to do that, then use server-side code to send the email. You might want to use a backend, but you need one. It can be one you run on your websites server or a third-party service.

How to send scheduled email in javascript?

I'm using SMTPJS to send emails by Gmail SMTP. Here my simple work code:
<script src="https://smtpjs.com/v2/smtp.js"></script>
sendEmail(to, subject, body){
Email.send(
"SITENAME noti.sitename#gmail.com", //from
to, //to
subject, //subject
body, //body
"smtp.gmail.com", //smtp host
"noti.sitename#gmail.com", //username account
"Noti-Password", //password account
message=>{
alert("sent");
}
)
}
What I need to do is sending an email that should be sent by date. For example after 2 weeks or after 30 days. So is that possible by adding some lines or doing an other way ?
I think it's not possible with only JavaScript For this you need to open your browser for that specific time it can be manage from the server side but as far my concern from client side it can be done with extension only that must be embedded in client browser. You can you use background or cantent script to send the message at the particular time
You can't do this in the Front End because JavaScript on the browser is only executed while the site is opened.
To do it you need a server to run a code every X time, that's a cron.
That code can be written in languages such as Python, JavaScript (Node.js) o PHP.
If you can host that on a website you probably can also run PHP so I recommend you to use PHP. This is how you would do it:
In your HTML use a Form to send the content of the email via POST to a PHP file.
Upload a PHP file that reads the POST parameters and saves a file (for example a JSON) that contains, for each email: the timestamp in which should be sent and the email content.
Upload a PHP file that reads the "pending emails to send" file and sends the emails that have a past timestamp and removes that mail from the file.
Set up a cron that runs the second PHP file every one day at 8am.

is there a way to send an email with data from input without php or javascript just pure simple html?

I have HTML form with a textbox where user enter his email - let say to register for a newsletter and a button to join.
When clicking the button I'd like to send myself an email with a constant subject like: 'a new user joined your newsletter' and in the body of the email have the text entered by the user.
So with PHP and Javascript code its possible - i'm looking for a pure html code that does the same (in my index.html file)
using <a href: mailto...> or <form action=mailto:... method=post> or <button onclick:mailto...> opens my mail application :(
Is there a way to send that email in the background (without opening the mail application) with the data from textbox in the email body?
if Yes to Q.1 then is there a way to add a fixed subject
No, there is no way you can send email using pure html. Email is sent over SMTP protocol. A browser operates in HTTP protocol. So it's not possible to send email even using pure javascript. Only server can send data using SMTP protocol.
No because you can not send an E-Mail without using an SMTP server. This server must be contacted by PHP or another server-side script (server must receive a form request and process it). You can not contact a SMTP server via pure HTML (that would be really insecure btw).
Regarding mailto: This only works if your clients have installed a mail client on their local machine. This mail client must be properly configured in order to - guess what - contact an SMTP server in order to send the mail.
However it is possible passing a subject via mailto:
https://css-tricks.com/snippets/html/mailto-links/

Mail script with just JavaScript and HTML5

Is it possible to create a contact form that sends the answers by email with only HTML5 and JavaScript? And if it is, how do I do it?
I don't think it's possible to do it from JavaScript directly via a mail function or so because the user's local machine can't be assumed to be running a mail server. There would be nothing to send the email from.
I'm not sure how "standards compliant" this is, but you can navigate to (by using links or document.location) to mailto:user#example.com or so which will begin composing an email in the user's standard email client, allowing them to send you an email directly. Though this will expose both their and your email address.
In the action field of the form, set the action as “mailto:youremailaddress” for example:
<form action="mailto:myforms#mydomain.com">
If you want to send the form data as plain text you can use the following
Add ‘enctype=text/plain’ in the form attributes. The form code becomes:
<form action="mailto:myforms#mydomain.com" enctype="text/plain" >
When this form is submitted, you will get the email in readable form.

Categories