Jump to content

E-mailing just only with javascript...


Muhammad_Bilal

Recommended Posts

Salam or Hello @ All,

It's me Bilal since a very long ago, today I'm posting this topic because I'm dive into a problem which is:

I want to send a email after collecting data from html form which is pretty simple with the help of PHP but can the same functionality can be performed by using just JavaScript only?

if so please discuss the possibilities on this topic. Don't be tell about the mailto function of the html because it is not good at all.

I'm waiting for your pretty responses......

Link to comment
Share on other sites

Javascript cannot send e-mails. HTML can use mailto to request the browser to open a mailing client, but if you want anything more than that you'll certainly need a server-side language, such as PHP.

Link to comment
Share on other sites

Thanks, for both of you,

Now i'm be concluded that sending e-mails is not possible with the javascript only some server-site language or other application is required, Correct?

But have you know any of these services through which I can send eMails without using server-site?

Have you know any service which can send email to gmail account using the client-side only?

If so, please share with me.

thanks again.......

Link to comment
Share on other sites

The problem is that Javascript does not have a way to communicate with a mail server. You can use ajax to send a request to a different port (although you'll need to change your browser's default security settings to allow cross-domain and cross-port requests), but it's going to be an HTTP request, not an IMAP or SMTP request. The bottom line is that Javascript alone cannot contact a mail server. The best you can do is use Javascript to send a request to a web server, which then contacts the mail server.

Link to comment
Share on other sites

I don't know of any such services but they may exist. You might have to create your own. Each form would have one of more hidden fields (magic numbers) that would validate the post and also identify the desired email destination. The service code would need to be smart enough to ignore floods from hackers.

 

--EDIT--

 

Apparently I am overlooking the limitations of cross-domain access.

Link to comment
Share on other sites

Saying Thanks once again to all,

Both of you clear that some server-site is must be required to sending requests to a mail server and then collecting information from them.

As justsomeguy said

"The best you can do is use Javascript to send a request to a web server, which then contacts the mail server."

I'm be asked that how to build such a system, basic algorithm something like this:

 

 

JavaScript collect the data from the HTML form when, submit button is clicked.

and showing message to the user something like: Data is sending....

Then Send this data using AJAX to the hosting server which then send the mail to the mail server .

After sending the mail hosting server reply back to the requesting site and tell the status of the mail i.e. send or not.

Then user message will change with the status of the mail i.e. Data has been sent if successful and An error if mail has not been sent.

The URL of the page doesn't change during whole process.

 

Please suggest how to write code for this.

I'm a beginner JavaScript user so it is very difficult for me to writing the xml requests or code like this.

Your help is appreciated......

Edited by Muhammad_Bilal
Link to comment
Share on other sites

I wouldn't recommend that way, personally. It's not that hard to setup basic email sending with an HTML form and a little server side scripting.

Link to comment
Share on other sites

After sending the mail hosting server reply back to the requesting site and tell the status of the mail i.e. send or not.Then user message will change with the status of the mail i.e. Data has been sent if successful and An error if mail has not been sent.

You have the correct process, but the server will not be able to tell if the mail was actually sent. It can verify that the mail made it to the mail server, but it cannot verify that the mail was actually delivered to the destination account.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...