简体   繁体   中英

How to send an email to a java program

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/

您需要有一个邮箱才能在此处发送消息,并且您可以使用以下代码阅读消息: 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM