How can I send a Email on my company domain by javascript? - javascript

I am developing a static website just for informative purpose. What I need is functionality that would let any webiste visitor request additional information by email (info#edugru.com). My domain name is www.edugru.com.
I am not using any database. It's just a static website.
So how can I add this email functionality by javascript in my app?

You have (at least) two choices :
Client side only, no server side scripts.
You can add something like this in the page:
Send email
Se a lot of useful other examples here: Can I set subject/content of email with using mailto:?
Clicking on the above link would open a new window of the default email client (if any) installed on the client machine. You will get a Thunderbird or Outlook or whatever email client is the default. The To, Subject, Body, CC, etc.. will be filled with the values you provided in the HTML code above. This is the maximum you can do in this approach.
The message will NOT be sent automatically. A human action would be necessary to hit Send button on the email client window. This requires the client machine to have a email client properly configured.
Using a server side script.
The only way to automatically send the message is to submit the data to a server side script (running either on your edugru.com or somewhere else) that would connect further (in a form or another) to a mail server and send the data. You can't achieve this using HTML and JavaScript only.
[Edited to detail the server side approaches..]
See two options below for sending the email from a server side script. I'm assuming you have PHP available on the server.
a. Use PHP mail function. See usage examples here: http://php.net/manual/en/function.mail.php
b. Use PHPMailer class for more complex options: http://phpmailer.worxware.com/?pg=tutorial

Try this:
<p>
This is an email link:
Send Mail
</p>

Related

Getting email headers from within an HTML email for tracking purpose

Posting question in StackExchange for first time. Apologies if this has issues...
Need to track email open.
This is something not very new and the approach generally used is to have a pixel in the HTML which calls a server URL asynchronously. By using this we get the number of opens for an email.
Now the issue is the email is send to a Distribution List (DL) and we have a requirement to track email open and also clearly state who has opened it..
Basically when a hit to server comes, it should says xxxx#mail.com has opened this email.
In my HTML if i have a way by whcih to capture the email headers, my requirement would be sorted... I would use Javascript to get the email headers and then when i call the server URL i will send across the details...
When i searched i found a POST which was doing something similar...
Read email headers in Outlook Web Access (OWA)
But this was for office application...
Also, i am not sure whether this would even work...
Any pointers is well appreciated....
I am specifically at the moment looking for exchange server...
In my HTML if i have a way by whcih to capture the email headers
You don't.
I would use Javascript to get the email headers
You can't run JavaScript in an HTML formatted email
The only identifying information you can get back from the email is the information you put it in it in the first place.
You can put a unique ID in a tracking pixel (increasing the chances of it being marked as spam) but that ID will be given to anyone who gets a copy of the email (including if it is forwarded automatically by a mailing list or manually by a reader). The tracking will also fire only if the image is loaded from the server (plenty of people keep email image loading turned off).
There is no way to find out who your email actually ended up with.

Zimbra mail server - Get Information about new incoming email

As you will all know that there are black list and white list in Zimbra mail server that will block or allow a new coming email. But it's quite inconvenient by this way to block an email. So I want to make a plugin in Zimbra mail server to filter email into spam and non spam category based on a list.
But the problem i met here is i can't get the information about a new incoming email address, here is email address and header. I've read some tutorials about writing a Zimlet, but it's all about making an action to get those information.
Can you guys tell me how to get those Information?
Thanks in advance :-)
This isn't, what Zimlets are made for. Zimlets are extensions to the Web UI. Perhaps it's possible to write a server extension for that, though I don't know currently, if there's an extension class for that.
I would use a "milter" for that. A milter is a way of "hooking" into the mail delivery process.
For an example, have a look at my "disclaimr"-milter: https://github.com/dploeger/disclaimr
Inside the milter you would use the Zimbra SOAP-API to fetch objects from the Zimbra server (lists for example).

Can I Send an Email using ONLY Javascript Without Having to Click The Send Button on the Email Client?

I created a form in HTML and when the submit button is clicked the onclick event calls the following function:
function ProcessSubmition(){
var stringEmailBody=BuildEmailBody();
var stringTo=document.getElementById("SubmittersEmail").value;
var stringSubject = "My Subject Text";
window.location.href = "mailto:"+stringTo+"?subject="+stringSubject+"&body="+stringEmailBody;
}
There are two requirements to my project:
No PHP is allowed on our server.
The person filling out the form must not be able to edit the data which contains a calculate price.
The Problem:
When the function launches, the mail client window appears and displays the message constructed by the function and the user must click the "Send" button in the mail client window.
Unfortunately before the user clicks send, they can simply change the calculated price to a lower dollar amount which obviously is unacceptable.
Is there any way to hide the mail client window and auto-sent? Alternately is there any other method I could use to solve the problem?
Thank you for any help you can give me.
Short answer: No
The JavaScript code that runs in the context of a browser is client-side code that can be manipulated by the end-users. For that reason, you should never rely on client-side code to perform any sensitive operations.
Basically, you will need some server-side support to do what you are tyring to achieve or it will never be secure. Now, if it's dangerous for you that the users can tamper with your code, it would also be dangerous for them if your code could perform tasks such as sending e-mails on their behalf without any form of approval.
Even if you could talk directly to the mail client like you asked and make the email being sent automatically, there's nothing that would prevent users from editing the JavaScript source that generates the message and change the message content.
Alternative? If you will never be able to use any server-side technology, Maybe you could simply send the form details by e-mail and do the pricing calculations in another process afterwards.

How to export html form data to json file

How do I save html registration form data into a JSON file then log in based on it, without using any server side scripting languages? I want to use only Javascript and jQuery.
HTML file "simple form" contains:
First Name, Middle Name, Last Name, User Name, Password, Confirm Password, E-Mail, Phone
When a user enters his data and clicks the register button, his data will be saved in a JSON file on the server. I have created this JSON file on the server as:
C:\inetpub\wwwroot\usersData.txt
And based on this file usersData.txt, when another user wants to register, I need to check the that user name is unique, if it is a unique user name, save his data back to the JSON file.
I also need to know how to update the password in the JSON file when I use a hypothetical change_password() JS function.
Under normal circumstances, you should not be able to modify files on the server from client side scripting. Allowing that would let a malicious user put anything into that file, or, depending on configuration, any other file the server can access.
Doing only authentication client side is also problematic. If the client can download the userData.txt, the malicious user would know every user's email, password and phone number; using the email and password he could probably login to the user's email account, and another bad stuff can happen, so please don't do it!
So, there's no way to properly do it clientside...
I think you would be better served by not bothering to collect the data -- client-side authentication can never be trusted. Don't try to build a system that pretends to be safe. Instead, make the insecurity very obvious: store the username in a cookie and let any user type any username into whatever field sets the username cookie. (The cookie is just so they don't have to re-type it all the time.)
If you don't care about security be upfront and honest about it.
If you plan to do authentication on the server side, which you really really really should, you have to have something listening on the server, either your code or delegate the authentication to some other system. There's no way to magically update a file on the server from javascript running in the browser.

detecting if a request is a post in jQuery

I'm trying to load a page differently if it is a post or a get, and seems like jQuery would have something so I could do
if (isPost())
{
// do something if this page was a post
}
I'm showing/hiding something based on the request type and want to do it specifically with javascript. I can easily do it with the framework I'm using, but don't want to.
The problem here is that you are confusing client-side with server-side.
GET, POST, PUT, DELETE, etc are all HTTP 'methods' that are sent to a server from the client (e.g.: the browser). The server then responds with the appropriate HTTP response, normally in the form of content that contains HTML.
POST/GET/etc have no context at the client side outside of dictating how a request should be sent to the server.
Think of the browser being your postal mailbox and POST/GET/etc being the method it was delivered. When someone sends you a piece of mail, they specify the method, such as first-class mail, overnight express, or same-day delivery. The Post Office handles the mail based on how it was received and sends the mail using the appropriate action. When you pick up your mail in the mailbox, you don't know if it got there via standard mail, overnight express, or same-day delivery. The only way you would know is any information that is on the envelope itself.
The solution to your problem would would follow this same principal. To resolve it, what you will need to do is include a hidden value that jQuery can pull in, either in the query-string, a special element, or as a hidden textbox that contains the HTTP method used to get the page.
This requires that server-side code be changed accordingly to push that information back to the client.
Hope that helps clear it up a bit.
i don't know if this is really possible in javascript. But you can check if there is a query string which is GET in the URL
if (location.search.length > 1) {
// your code.
}
location.search returns the query string in the URL
http://example.com/index.html?id=1&value=3
in this case location.search will be ?id=1&value=3 including the question mark.
so if it is present then you have a GET

Categories

Resources