Package gnu.mail.providers.smtp
Class SMTPTransport
- java.lang.Object
-
- javax.mail.Service
-
- javax.mail.Transport
-
- gnu.mail.providers.smtp.SMTPTransport
-
public class SMTPTransport extends Transport
This transport handles communications with an SMTP server.- Version:
- 2.0
- Author:
- Andrew Selkirk, Ben Speakmon, Chris Burdess, Arend Freije
-
-
Field Summary
Fields Modifier and Type Field Description protected org.jpackage.mail.inet.smtp.SMTPConnection
connection
The connection used to communicate with the server.protected java.lang.String
localHostName
-
Constructor Summary
Constructors Constructor Description SMTPTransport(Session session, URLName urlName)
Creates a newSMTPTransport
instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Close this transport.java.lang.String
getGreeting()
Returns the greeting banner.protected boolean
protocolConnect(java.lang.String host, int port, java.lang.String username, java.lang.String password)
Connects to the SMTP server.void
sendMessage(Message message, Address[] addresses)
Send the specified message to the server.-
Methods inherited from class javax.mail.Transport
addTransportListener, notifyTransportListeners, removeTransportListener, send, send
-
Methods inherited from class javax.mail.Service
addConnectionListener, connect, connect, connect, connect, getURLName, isConnected, notifyConnectionListeners, queueEvent, removeConnectionListener, setConnected, setURLName, toString
-
-
-
-
Method Detail
-
protocolConnect
protected boolean protocolConnect(java.lang.String host, int port, java.lang.String username, java.lang.String password) throws MessagingException
Connects to the SMTP server.- Overrides:
protocolConnect
in classService
- Parameters:
host
- the name of the host to connect toport
- the port to use (-1 for the default port)username
- the usernamepassword
- the password- Returns:
- true on success, false if authentication failed
- Throws:
AuthenticationFailedException
- on authentication failureMessagingException
- for non-authentication failures
-
getGreeting
public java.lang.String getGreeting() throws MessagingException
Returns the greeting banner.- Throws:
MessagingException
-
sendMessage
public void sendMessage(Message message, Address[] addresses) throws MessagingException, SendFailedException
Send the specified message to the server.- Specified by:
sendMessage
in classTransport
- Parameters:
message
- the message to be sentaddresses
- the addresses to send this message to- Throws:
SendFailedException
- if the send failed because of invalid addressesMessagingException
- if the transport is not connected
-
close
public void close() throws MessagingException
Close this transport.- Overrides:
close
in classService
- Throws:
MessagingException
-
-