0
Das Folgende ist mein Code. Dies wurde erfolgreich ausgeführt. Aber ich habe keine Mail in meinem Posteingang gesehen. Bitte helfen Sie mir.Apache James: Mail-Server
import java.util.*;
import javax.mail.*;
import javax.mail.internet.*;
public class SendMail {
public static void main(String args[]) throws Exception {
String fromAddress = "[email protected]";
String toAddress = "[email protected]";
Properties properties = new Properties();
properties.put("mail.smtp.host", "localhost");
properties.put("mail.smtp.port", "25");
properties.put("mail.transport.protocol", "smtp");
try
{
properties.put("mail.smtp.starttls.enable", "true");
Session session = Session.getDefaultInstance(properties, null);
Message message = new MimeMessage(session);
message.setFrom(new InternetAddress(fromAddress));
message.setRecipients(Message.RecipientType.TO, InternetAddress.parse(toAddress));
message.setSubject("Email from our JAMEs");
message.setText("hiiiiii!!");
Transport.send(message);
System.out.println("Email sent");
}
catch (MessagingException e)
{
e.printStackTrace();
}
}
}