in my webapplications whihc runs on tomcat on widows i want to send email to many different people
for example whenever a new tutials is uploaded on my site an email shold go to all the registed user on my site.
simlarly whenever some other event occors i need to send the email to some selected users whose emailid are picked up from database.
I want a jar which can be used to send such messages.
I wil pass a array of receipienst to it.
are there some free jars available for this ??
jars shold me able to queue the msgs and send to the recipients
let me explain in detail
You need JavaMail
Check out commons email
The "queue" ability usually requires a SMTP server which traditionally is provided by your Internet Service Provider. You then use e.g. JavaMail to generate all those mails you need to send and forward them to the SMTP-server and let it handle all the details.
If you really, really need to run your own SMTP-server, I believe James can do it (http://james.apache.org/) but I would recommend the ISP approach.
Related
I'm working on a project I'm Java with regards to outlook.
Here I'm able to do all the functions like Read a mail, write a mail, reply to a mail etc...
But now we've been thinking of taking it to the next level.
Our plan is as below.
We have an email address like info#myDomain.com, when ever an email is sent to this address, I need to reply them. Here basically customers send an email asking for some data, and we've the data available in our portal, and we just need to send it.
The response would be Like thank you for contacting us, we will get back to you soon. Mean while please look into this {URL}.
And this has to be done automatically when ever there is an email hit to this particular email address.
Couple of questions:
- should my machine be on the whole day to get this thing done.
- is there a way that a Java application can automatically monitor my inbox to see for this case match.
- Also, can I have this running in the bg.
Can someone please point me into the right direction/approach where can I can start working on this task.
Thanks
when ever an email is sent to this address, I need to reply them.
For this you need to monitor your email account fro incoming emails. Here is one of the way to do this
The response would be Like thank you for contacting us, we will get back to you soon. Mean while please look into this {URL}.
Once you receive an email (using above email monitoring approach), you need to call a method that sends the reply with above format
And this has to be done automatically when ever there is an email hit to this particular email address.
Above two steps accomplishes this task.
should my machine be on the whole day to get this thing done
Basically, you will need an application server (like tomcat) where your above java program is deployed. So, yes this server needs to be running and available all the time.
is there a way that a Java application can automatically monitor my inbox to see for this case match
Check point 1
Also, can I have this running in the bg
You can run tomcat as a service in windows (more info). It has many advantages, automatic startup on boot being the one. Similar implementations are also available for other OS.
So, in short, this can be accomplished. It is bit complex but not much difficult. Cheers
I have some automated functionality built into my web app that sends email daily to remind customers of appointments etc. Basically I use an auto scheduler that starts each morning at 7 am, checks the database for customers that need to be emailed, and sends the messages. This is great, but beyond actually sending the email I am completely in the dark.
Can I somehow verify that an email address is actually a real email
and the email has been successfully sent?
What about checking for messages that were delivered to a spam folder
of some sort?
Diving even further...I know there are email services out there that
can provide statistics based on the amount of people who actually
opened the email. How do I check for this sort of thing?
My understanding is (at least for my first question) that I need to check the sender email address for returned or undeliverable emails and deal with them accordingly, but how do I do this programatically with Java? Do I need to implement another automatic daily process that checks an email account for undeliverable emails, handles the error, then removes the message? I assume that because of relay servers etc, an undeliverable error will not be available immediately because of relay servers etc.
I understand this is a slightly vague and loaded question so i'm not necessarily looking for a complete solution, but more or less some advice that will help me get started. I'd rather not use an external service.
Emails are usually fire and forget, so there is no standard way of tracking them down. Having some third party send emails might reduce the chances of your mail getting sent to the spam folder, but sometimes, the mail client seems to learn what emails you delete without even reading and starts trashing the emails immediately.
That being said, you can take a look at this and this previous SO threads. Depending on the content of you mail, there might be some possibilities for you to get some sort of response back.
As for being able to check which email is valid or not, you might consider using some sort of activation mechanism. You basically send them a mail and in it you include a link to which the user will have to navigate to activate some sort of service. If the user activates the link, than you know that they have access to the given email account.
I'd like to write a program, probably a servlet or something to run on the a google app engine that I can send an email to. So not a program to send email, but one that can receieve it and parse it.
My question is, what code or API are out there that can receive an email?
Basically on your google app engine you can use an inbound mail service.
Please see this documentation for more information.
http://code.google.com/appengine/docs/java/mail/overview.html#Receiving_Mail_in_Java
You cant send an email to a program, you send an email to a server, so what you are looking for is a way to access an email server via your program. Unfortunately there is no single solution here, you need to configure your program for every different email account/server you want to access. (If you have ever set up an account in outlook or something like it you will get the idea)
For example here is a link to the gmail api, you could use this to access gmail accounts
http://code.google.com/apis/gmail/
You need to have a mailbox to send message there and you could read messages with the code like this: http://www.java2s.com/Code/Java/Network-Protocol/GetEmailMessageExample.htm
This can be done with a built in Java library.
javax.mail
Check out this link. It should be able to help you get started.
This won't work for every mail server, but depending on your setup it might help.
To send an email to a Java program, that program must be running. Generally that means a server style (aka service) receiver is favored.
For the email to be received, the Java service must understand an email protocol. There are a number of protocols, but SMTP is the standard for receiving email. Once you have a service that understands SMTP protocol for receiving email, you have written a mail server.
Note that most people don't care to write a mail server, as a mail client needs to connect to the server and pull the email to make it readable. Keep this in mind when designing the solution to your problem.
I'm writing a program, that sends email messages and want to know when the receiver receives the email message I've sent to him. How can I do this using JavaMail API?
If I use SMTPMessage, how exactly to deal with the result after I've set the notify options?
SMTPMessage smtpMsg = new SMTPMessage(msg);
smtpMsg.setNotifyOptions(SMTPMessage.NOTIFY_SUCCESS);
There is no standard way of doing this that's accepted and honored across the board. I see that you have some options, though:
Add a header "Return-Receipt-To" with your e-mail address in the value. If the recipient of the e-mail has a client which honors this header, then a return receipt will be sent to you when the e-mail is opened. This is not reliable, mind you, as the user can always decide not to send the receipt, even if he has a client that supports it.
Add an image into your e-mail that loads from your server and put a parameter on the image that includes the user's e-mail address. When the e-mail loads, the image will load from your server. Write a script that collects the e-mail parameter and then delivers a blank image. This is also not reliable, however, as many mail clients prompt users if they wish to download images and they can always choose not to. Also, some (mostly older) e-mail clients do not support images.
Perhaps the most reliable way is not to include the message in your e-mail at all. Include only a link to a website where the message can be read, and include their e-mail address or a unique code in the link. This way, you know exactly who read the message. Of course, this has the downside that people aren't actually getting the message in their inbox, and they also may choose not to go to the website to read it.
Ultimately, I think you're going to have to come up with a creative solution to solve this problem, unless you're happy getting spotty results.
Ok, this is an old discussion, but:
I've found a simple and working solution here (link in spanish).
You just need to add one more field to the header of the message. To achieve this you must use method addHeader of Part class, implemented by Message class. This method receives 2 parameters, type and value of header.
To get confirmation you must add this header:
Disposition-Notification-To
And the value is the mail where we want to send the confirmation answer:
message.addHeader("Disposition-Notification-To","mail#example.com");
ATTENTION: be aware that, nowadays, a lot of mail servers like gmail are discarding this requests, so this will not have effect, but, if you are sure (like me) receiver server allows this, will work like a charm.
please see my answer here (when this questioned was asked about ruby on rails). Tis basically the same answer.
Email open notification - ruby on rails
There is another approach to finding out whether an email has been received or not, it's getting undelivered emails. I've seen a rather good Java implementation here.
They used javax.mail (for mail processing) and guava (for processing strings and collections).
Just add a dummy image with display set to none in your message.And set the src attribute of this image to the url you want to call
You can use SMTP message and request for a delivery status (I don't know if it's coming when the provider receive the mail or if it's when the user open the mail).
JavaMail don't support directly these feature directly and you have to read the RFC 3464.
I also find this thread with examples but didn't try it javamail
You can also look at websina
I have java web application to which I'd like to add emailing capabilities, however, I'm unsure what is needed to accomplish this. Specifically I want my app to be able to:
Send emails confirming sign-up
Allow users to send emails to one another, using my app's domain i.e. dan#my-app.com
From my research it seems I'll need a mail transfer agent (MTA) like Postfix and possibly a IMAP server like Courier; but I don't understand the need for the IMAP server.
Thanks.
You need code inside your web app to create and dispatch the email into the SMTP-world. Usually JavaMail is used for this, and you can either enclose it in your web application or (preferred) have the web container provide a correctly configured instance through JNDI. This is vendor specific.
If you do not have a SMTP-server for JavaMail to connect to (frequently this is Exchange for Windows shops), you can either get one running (ask your IT administrator) or use Google Mail or Hotmail or others if it is ok for your web application to send mail through them. It is a bit tricky to use GMail as a SMTP-server, but when set up correctly works very well.
You will need the SMTP-server, as it handles all the boring details regarding MX records and resending if the SMTP-server does graylisting, etc. etc.
Oh, and IMAP is for getting delivered mail, not sending mail. You don't need it.
If it's a Java web app, then the server part is a servlet. Given an email message sent from a client form, your server needs to send that text off as an email.
There's code in the Java EE stack to do this, or you can specifically download JavaMail. This will allow your programs to act as mail clients.
Your MTA receives messages from your servlet and sends them to the users. So far so good.
But you also need a postbox, i.e. the equivalent of a mail in-box for your users. Postfix, QMail and others offer a basic "flat" mailbox model, where mail is simply stored until the client picks it up, and then (usually) deleted. Access is via POP3. IMAP offers a lot more organizational capability, i.e. the ability to specify hierarchies of nested mailboxes, to transfer mails between them and so on. You probably won't want to create a GUI front end to all that complexity, so I'd guess you don't really need an IMAP server. You do, however, want a relatively simple POP3 server to allow your servlet to access the mailboxes via TCP/IP. This is usually part of the "standard" email server packages.
To have your own domain known to the world, you need access to the MX records of your DNS service, i.e. you have to set up one or two of your hosts, on an Internet-facing address, to be your post office.
Finally, if you want to save yourself a lot of trouble, be very careful in configuring your MTA (SMTP server) such that there is no chance for it being used as an open relay. i.e. it should not be possible for your users to send mail to the outside world in general (or hackers will find a way to abuse your Web interface to do this), and mail from the Internet should not reach your users. Most importantly, there should be no way for mail from the Internet to be forwarded to someplace else in the Internet. Find an open relay testing service (they're free) on the 'net and get one to run a test on your configuration once you think you're done.
EDIT:
Looking at Thorbjorn's answer, I realized you probably don't want your users receiving their mail through your app; they probably already have email providers and accounts of their own. In that case, you don't need to worry about inbox capability or a POP3 server. You could consider offering full email services at your domain but that's a very thankless job and if you have any choice, leave that dirty work to GMail, Yahoo, Hotmail and their ilk. Whatever service you provide will never please your customers enough, and you'll be fighting spam and other crime every day.
For starters your server has to have mailing abilities. In linux land sendmail is usually what this will be.
Additionally, check out javaMail.
http://www.oracle.com/technetwork/java/index-jsp-139225.html