Authentifizierung am Mailserver

Status
Nicht offen für weitere Antworten.
C

Chris20

Gast
Hi, ich habe fogendes Programm:

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
 
Status
Nicht offen für weitere Antworten.

Ähnliche Java Themen

Neue Themen


Oben