send an email from a HTML/CSS/JS app - javascript

I am developping a mobile HTML/CSS/JS app with a contact form.
For now I use a "mailto" to send the message, but it is not efficient because the user is sent to his email app before sending.
How can I send the message directly from the app ?
thanks

Write an application that runs on the server of you website.

If you don't want any server side code then you either need to use any third party Javascript application. (API)
or you can try this also :
Email
1) For third party API you can try this also (Never tried it but looks good enough)
www.mycontactform.com
2) Mail Chimp (as Robert suggested)

You will not be able to do this purely from javascript. You will need a server side component to connect to an SMTP server in order to be able to send your email.
Even if you were able to somehow develop an SMTP client for javascript, the security risks involved would much outweigh the advantages. All your users will need to do to send email as you, is to go through your javascript code and get your SMTP credentials.

You can't do it by client side language. Use server side language like php to do that.
<?php
mail(to,subject,message,headers,parameters);
?>
Copied from w3school

Related

authentication form using Electron (Atom shell) and PHP+mysql server only

I want to authenticate users of my app, I know how to do it using php on client but Electron can't use PHP at client side
Is there a way to authenticate users from mysql in Electron's app?
I need something like $_SESSION (PHP)
Thanks for the help :D
First never authenticate on the client side. Always on server side. Use OAuth´s PHP Implementation or write you own implementation. Then simply use node´s native https request and return json from your server, PHP script. Please do a lot more research on application design and security.

Sending email from webpage without any server side support

An HTML form has been filled out and now it's time to send the data via email. The server hosting the HTML is not running any server side scripting language like PHP, ASP, CGI etc. The owners don't want the email coming from outside of their walls, so no SMTP.js.
A fellow at work provided the SMPT server and port 25 and says to use Websockets, or to use Flash. I'm under the impression that port 25 is blocked by browsers, and they will need some kind of server side support to send an email. Alternatively, to use a mailto link to utilize their computer's email client.
Maybe I'm not up on current technologies. Are websocket the way to go? Don't they need a websocket server running to answer those calls?
Is there another solution to sending email from Javascript directly to an SMTP server?
Thanks to some highlighting, looks like I had SMTP.js confused with smtpjs, which just uses someone else's server to send mail. SMTPJS needs node.js, which they aren't running. Darn.
You are right about websockets. Its not a "tcp socket" you can use for smtp communication.
And if you could, you would have to make sure the clients can reach your smtp server. Many isp blocks port 25 to other servers then their own to reduce spam from their network. Forget about flash. Its dead and will give you the same problem with blocket smtp port.
I would solve this by using a web server with support for server side code. If you cannot move your webpage to that server, you can use cross site scripting to communicate with a server with support for server side code.

Can I send sms using Sinch with Squarespace, which does not give access to server side code

I need to send SMS using Sinch from a Squarespace app, which does not provide access to server side code. I am wondering if their JavaScript SDK can do it, but I can't seem to figure out any help of this. Has anyone does this before.
You can but you should not do that because you secret will be exposed so any one could use your account. The code that sends sms should be on server side (in any language you want)

Send mail from my web page with ajax

I am trying to build an error reporting service for my web page. The idea is simple. If an error pops up in a client browser while visiting, I want an error handler to send me notofication about it. My page is static, so I want to avoid adding server side components for that. Can I use ajax request for example and use a gmail account to send the mail to me? I guess ajax does not do cross domain? Maybe there is some other option?
EDIT
My primary language is Java.
What about Google App engine? I can host an app there that can send email. Not sure how I can interact with that app though?
Other idea - if I must use server side component, maybe the best option is to find ready web application (I have java application server running on my host) that sends mail and deploy it. Then I can contact the mail sender with Ajax.
The best way to do this is the following:
You need to set up a web service that accepts the error information.
The web service will generate the email content and send to gmail.
The client (via ajax) will consume this web service and post the error information.
This way your credentials are secure on your server. If you indicate the development language, we may be able to help with a bit more details.
Bob
If you were to be using GMail then you would:
Be using a server side component (GMail's scripts!)
Have to expose your GMail credentials to every visitor (bad!)
Do cross domain Ajax with a third party service (which requires a pretty recent browser and the cooperation of the third party).
You need your own server side handler for this.
You can, ... theoretically. You do not want to, because you would have to send the authentication information for your e-mail account to the client.

Send Email, not from my server

Is there any widget, or similar, that i could use to send an email for me?
Something like i pass a post in some pre-defined way, this server would get it, parse it and send it to some email for me?
More of a curiosity than a valid question itself...
There's the classic formmail, a CGI script from the days of yore, which now seems to have a commercial, hosted version. Most web hosts have formmail or some variation of it installed; check the documentation for your host.
Hardly in a public way, as it would most certainly be misused by spammers within a day or two.
You can set something like it up easily using a scripting language like PHP on an own server.
Yes; it's called a server-side script.
You can do it in a couple of lines of ASP.Net. (See the SmtpClient class)
It's also called an open relay; you'll need some way to prevent it from being used by spammers.
You need server-side scripting for this, using a language such as Perl, PHP, Ruby, Python, any .Net language, or Java.
Typically what happens is that your web page will send a POST message to your web server with the recipients, body, and perhaps attachments of the email as POST parameters.
The server side script will parse the POST parameters and run a SMTP or IMAP session with your mail server to send the mail, and the script will pack the parameters from the POST message into that session with the mail server. This is the same kind of SMTP session that your mail client (e.g. Outlook, Thunderbird, Evolution,...) uses to talk to your mail server (e.g. Exchange, gmail, sympatico.ca,...).
The server side script will then render a web page saying whether or not the mail succeeded.
You need to figure out what your web host offers as a server side scripting language. All of the major server-side languages have libraries that allow you to both parse parameters from POST messages and to run a session with your email server. I have personally used libraries from Perl and Ruby on Rails for both parsing and talking to mail servers, and they were straight-forward to use.

Categories

Resources