Folge dem Video um zu sehen, wie unsere Website als Web-App auf dem Startbildschirm installiert werden kann.
Anmerkung: Diese Funktion ist in einigen Browsern möglicherweise nicht verfügbar.
package de.tutorials;
import java.io.IOException;
import java.util.Properties;
import javax.mail.Message;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeBodyPart;
import javax.mail.internet.MimeMessage;
import javax.mail.internet.MimeMultipart;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class ExampleMailSenderServlet extends HttpServlet {
Session mailSession;
public void init() throws ServletException {
super.init();
Properties properties = new Properties();
properties.put("mail.store.protocol", "pop3");
properties.put("mail.transport.protocol", "smtp");
properties.put("mail.user", "foo.bar");
properties.put("mail.pop3.host", "pop3.someProvider.de");
properties.put("mail.smtp.host", "smtp.someProvider.de");
properties.put("User", "foo.bar");
properties.put("Password", "somePwd");
properties.put("mail.from", "foo@bar.de");
mailSession = Session.getInstance(properties);
}
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
Message message = new MimeMessage(mailSession);
try {
message.setSubject("Test Nachricht");
message.setRecipient(Message.RecipientType.TO, new InternetAddress(
"tom@tutorials.de"));
MimeMultipart mimeMultipart = new MimeMultipart();
MimeBodyPart textPart = new MimeBodyPart();
textPart.setText("ABCDEF");
textPart.setDisposition(MimeBodyPart.INLINE);
mimeMultipart.addBodyPart(textPart);
message.setContent(mimeMultipart);
message.saveChanges();
Transport.send(message);
} catch (Exception e) {
e.printStackTrace();
}
}
}