C
Chris20
Gast
Hi, ich habe fogendes Programm:
Bei Mailservern im Web muss man sich allerdings noch authentifiezieren, weiß jemand, wie das geht?
Danke im Voraus!
Chris
Code:
package mail;
import java.util.*;
import javax.mail.*;
import javax.mail.internet.*;
public class Mail
{
public static void postMail( String recipient,
String subject,
String message, String from )
throws MessagingException
{
Properties props = new Properties();
props.put( "mail.smtp.host", "mail.mra.man.de" );
Session session = Session.getDefaultInstance( props );
Message msg = new MimeMessage( session );
InternetAddress addressFrom = new InternetAddress( from );
msg.setFrom( addressFrom );
InternetAddress addressTo = new InternetAddress( recipient );
msg.setRecipient( Message.RecipientType.TO, addressTo );
msg.setSubject( subject );
msg.setContent( message, "text/html" );
Transport.send( msg );
}
public static void main( String args[] ) throws Exception
{
postMail( "<name@gmx.de>",
"Test",
"Es funktioniert!",
"webmaster@bonst.de");
}
}
Bei Mailservern im Web muss man sich allerdings noch authentifiezieren, weiß jemand, wie das geht?
Danke im Voraus!
Chris