How can I send a confirmation email to users of my application? - java

I have designed a chat application where different users can create the account, but I do not know how to send a confirmation email to the users. Since I collect their e-mail address in the registration form, how can I send mail to those addresses in Java?

First of all, you need a SMTP server. It's required to be able to send emails. You can make use of the SMTP server associated with your own existing email account, such as the one from your ISP or public mailboxes like Gmail, Yahoo, etc. You can find SMTP connection details at their documentation. You usually just need to know the hostname and the port number. The login details are just the same as from your email account.
You're however restricted to using your own address in the From field of the email and usually also in the amount of emails you're allowed to send at certain intervals. If you'd like to get around this, then you need to install your own SMTP server, for example Apache James, which is Java based, or Microsoft Exchange and so on.
Then, to send an email using Java code, you would need the JavaMail API or the more convenienced Apache Commons Email.

This looks like a good site for you: http://www.javacommerce.com/displaypage.jsp?name=javamail.sql&id=18274
Google 'send mail java'

The easiest way of doing this really depends on the environment that your JVM is running in.
If you're running in a standard Linux/UNIX environment and don't want to faff about with extra libraries, then one way is just to "manually" call sendmail (e.g. via ProcessBuilder). As with executing commands generally, you just need to be slightly careful that you don't just pass user input as parameters without screening them.

Related

how send email from android application directly?

I want the email to be sent immediately, currently the application is showing me installed email applications in device where I can recompose the email before sending, I want to send the mail directly without showing installed applications.
I Know javamail but need email .. other user can decompiler app and theft email :)
The way to go is to send the mail via some server, not directly from the device. You would, for example, connect to a REST API that sends out the email for you. Sending an email directly from the device from the user's email address is not (and should not be) possible
There are two ways to send email from android application directly without any intent
using SMTP & JavaMail API follow the link for details
using Webservice( for example PHP script ) so there is a server side code and you hit that URL with param like ( name,subject etc) so basically PHP code send mail at the end and it's very easy to use .
Personally, I suggest you use Webservice because it's simpler than first approach.
** Edit: You can save email in sharedpreferences or database and fetch it from there when you try to send mail rather than hardcoding it to avoid theft email risk.(directly putting mail address inside code)
Anyway you can prevent other from getting your full source code.See this answer

Setting up and customizing mail server to store mails in desired way

I'm creating a website(say somesite.com) in Java. A part of the website is: users are provided with e-mail address (username#somesite.com)
and can send & receive emails using the e-mail address and the website.
Now, the problem is to setup a mail server. I tried hMailServer but hMailServer uses its own database tables which is very difficult to
use with the website database design.
Is there anyway to use mail server but store those emails in the way I want
(in website database tables)?
I don't know if this reach your expectation, but take a look at Apache James:
http://james.apache.org/server/index.html

Best way to send an E-Mail from a java Application

I've been searching for the best way to send an e-mail with an attachment by my java application. I want to use this as an users bug report with logger files. The recipient should be my own e-mail address. I'd prefer the use of an e-mail client.
I tried the following:
Send an e-mail with user authentification like this. I don't want to use this, because the user would need to reveal his e-mail account and password. Furthermore, I'd have to set the properties for every e-mail adress, which is impossible.
Send an e-mail directly to my own e-mail address like this in Listing 16.16 (didnt found an english example). The problem is every e-mail server is using POP authentification nowadays, that means the recipient e-mail server won't accept my e-mail.
Using the mailto URL syntax like this. Doesn't work aswell, because the attachment function isn't working properly in every e-mail client. Best solution so far is to brief the user to add the attachment by himself, after I would put it to his desktop. Or upload the data and add a link to the e-mail body.
The last way I've found is this one. As you could assume this won't work either, because the localhost needs to be connected to the internet and capable enough to send an e-mail.
Hopefully I explained my problem well enough. Is there a different way to send bug reports?
The generally accepted way to get around the problems you describe is to keep all the email logic server side, and then have your application call a web service with the appropriate parameters. It's pretty easy to knock a PHP script / servlet up that will do the job and then send the results on via email, put them in a mysql database or so on.
However, if you can't / don't want to / won't keep this server side, I'd recommend using JavaMail to create a MimeMessage, then using writeTo() to write this to an EML file.
You can then do the usual:
Desktop.getDesktop().open(emlFile);
...which will open the EML file with the default application for handing those files, which is almost always the mail client. Still not foolproof, but if you're determined on sending the email from the client directly I think that's as good as you'll get.

Be able to send an email to an email address, and have that appear on a web page

I want to be able to send an email to an email address, and then have it appear on a web page. Is this possible?
My guess is you'd have to write your own email server, something which I am not capable of doing. So I am assuming this won't be possible for me.
But if there is some way it can be done, that would be great. I generally program in Java and use Tomcat as my app server.
No, you wouldn't have to run your own SMTP server. You'd simply need to be able to retrieve mail from a POP3 or IMAP server, using something like the mail client API found in javax.mail.
It would be up to you to decide how much control you'd give to users. For example, who specifies the IMAP settings? Who decides which messages to fetch and display? Maybe that's all pre-configured. Maybe you write full-featured, web-based email client that can send messages as well as retrieve. This is all determined through the design of your web application.
You don't need to write your own mail server. You can use an ordinary (external) mail server and poll its inbox via POP3 or IMAP from your software. This introduces a short delay up to the full poll interval, but that might or might not be acceptable for you.
I can't give you a good tip for a email client lib to use for that, though.
Here is a simple example of sending email trough Google's SMTP server.

The quintessential email listener / mini server in Java or .NET

I'm embarrased of how I'm unaware of SMTP / POP3 / IMAP protocols,
as much as I thought I know HTTP and TCP/IP it apears that I took email as granted, and never had to write any piece of code that will do other than sending an email via an existing SMTP server.
My task is to write an incomming email channel and I would like to hear what is the basic aproach
What I need is the ability to listen to a specific email address, and capture the body, subject and attachment of that email for further processing.
I understand you want to programatically recieve mail...use subethasmtp (much lighter and easier than james etc, works very well.
If you want your server to receive e-mails, it's an SMTP server that you need.
(You'll also need to make sure that the e-mail address is set up to be sent to that server, via the MX entry in the DNS.)
Note that, depending on how you want to install this service, you might not need to write an SMTP server yourself (or even use a library). Existing SMTP servers are often capable of delegating the processing of an e-mail to external applications.
You could use somelike Postfix and configure it to use pipe for that address, to send the e-mail to process to the program of your choice (including one that you develop yourself). I'm fairly sure Exim, Sendmail and other MTAs have similar features.
With this sort of configuration, your application would usually need to be able to read the e-mail from the standard input (and have the ability to split/process headers and body), but that's usually much simpler that writing an MTA/SMTP server.
If you really want tighter integration with the MTA, perhaps this could be a good starting point (I've never tried it): http://james.apache.org/
An SMTP server is usually how you'd refer to an outbound mail server; it sends mail.
POP and IMAP allow you to connect to a mail server, to read the mail that's already been received.
You need the receiving/server side of SMTP, and you might benefit from reading up on MTA; mail transfer agent.
You might also be interested in reading about SMTP proxies; so, sent mail would go through your server - and could be filtered/listened to, I suppose - and then get sent further to it's actual recipient.
Use the JavaMail API

Categories