Send Email, not from my server - javascript

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.

Related

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.

Password encryption at client side for html servlet

I have a webapp using the tomcat base. The webpages are made solely using HTML5 technology and no jsp and spring.
I have a register user and login page, which is directed to a login servlet to validate the user credentials. I'm not using a HTML form in the registerUser page and login html. I am just using a simple HTML table to take the input.
I need to secure my password at the HTML before sending it to servlet by using either using JavaScript or jQuery. I don't want my password to be hacked while sending data by post request to servlet.
If you can, use HTTPS. It protects you against much more than any alternative 'client-side' solution could possibly achieve.
If you don't use HTTPS, you are not protected against man-in-the-middle attacks. Which means that an attacker could intercept your website while it is being delivered to a client and remove any client-side encryption / hashing / protection before sending it to the victim.
Which in turn means that no matter what you attempt at the client side (password hashing, asymmetric encryption, shared secrets, signatures) will basically just be 'security by obscurity', nothing more.
You should configure the Tomcat server for HTTPS. Any encryption technique that you use in Javascrpt would be revealed in the source code making it useless.
You can find detailed instructions on how to configure HTTPS here:
http://tomcat.apache.org/tomcat-8.0-doc/ssl-howto.html

send an email from a HTML/CSS/JS app

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

HTTP5, Jquery client side email sending

Main target is to implement instant annonymous e-mail sending from web by client side script. Don't know if it`s event possible, but maybe you know some workarounds, or maybe some e-mail providers allow to send annonymous e-mails by posting data or have some API for that..
Found how to send mail to gmail by javascript, but problem is you need to have gmail account..
Thanks!
You could have a server-side script set up to watch for HTTP requests that contain a special key or API that would send an email based on hard-coded parameters, or parameters the request contain. On the client-side, you would just set up an AJAX request to call this server-side script. You could use Perl, PHP, Python, etc. to accomplish this.

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.

Categories

Resources