You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by no...@apache.org on 2003/05/07 05:04:32 UTC
cvs commit: jakarta-james/src/java/org/apache/james/transport/mailets RemoteDeliverySocketFactory.java RemoteDelivery.java
noel 2003/05/06 20:04:32
Modified: src/java/org/apache/james/transport/mailets Tag:
branch_2_1_fcs RemoteDelivery.java
Added: src/java/org/apache/james/transport/mailets Tag:
branch_2_1_fcs RemoteDeliverySocketFactory.java
Log:
Added Hontvari Jozsef's patch to use a socket factory in order to specify outgoing bind address
Revision Changes Path
No revision
No revision
1.33.4.8 +23 -1 jakarta-james/src/java/org/apache/james/transport/mailets/RemoteDelivery.java
Index: RemoteDelivery.java
===================================================================
RCS file: /home/cvs/jakarta-james/src/java/org/apache/james/transport/mailets/RemoteDelivery.java,v
retrieving revision 1.33.4.7
retrieving revision 1.33.4.8
diff -u -r1.33.4.7 -r1.33.4.8
--- RemoteDelivery.java 8 Mar 2003 21:54:08 -0000 1.33.4.7
+++ RemoteDelivery.java 7 May 2003 03:04:31 -0000 1.33.4.8
@@ -119,6 +119,10 @@
private int deliveryThreadCount = 1; // default number of delivery threads
private String gatewayServer = null; // the server to send all email to
private String gatewayPort = null; //the port of the gateway server to send all email to
+ private String bindAddress = null; // JavaMail delivery socket binds to this local address. If null the JavaMail default will be used.
+ private boolean isBindUsed = false; // true, if the bind configuration
+ // parameter is supplied, RemoteDeliverySocketFactory
+ // will be used in this case
private Collection deliveryThreads = new Vector();
private MailServer mailServer;
private volatile boolean destroyed = false; //Flag that the run method will check and end itself if set to true
@@ -198,6 +202,14 @@
t.start();
deliveryThreads.add(t);
}
+
+ bindAddress = getInitParameter("bind");
+ isBindUsed = bindAddress != null;
+ try {
+ if (isBindUsed) RemoteDeliverySocketFactory.setBindAdress(bindAddress);
+ } catch (UnknownHostException e) {
+ log("Invalid bind setting (" + bindAddress + "): " + e.toString());
+ }
}
/**
@@ -713,6 +725,16 @@
if (gatewayPort != null) {
props.put("mail.smtp.port", gatewayPort);
}
+
+ if (isBindUsed) {
+ // undocumented JavaMail 1.2 feature, smtp transport will use
+ // our socket factory, which will also set the local address
+ props.put("mail.smtp.socketFactory.class",
+ "org.apache.james.transport.mailets.RemoteDeliverySocketFactory");
+ // Don't fallback to the standard socket factory on error, do throw an exception
+ props.put("mail.smtp.socketFactory.fallback", "false");
+ }
+
Session session = Session.getInstance(props, null);
try {
while (!Thread.currentThread().interrupted() && !destroyed) {
No revision
No revision
1.1.2.1 +156 -0 jakarta-james/src/java/org/apache/james/transport/mailets/Attic/RemoteDeliverySocketFactory.java
---------------------------------------------------------------------
To unsubscribe, e-mail: james-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: james-dev-help@jakarta.apache.org