You are viewing a plain text version of this content. The canonical link for it is here.
Posted to taglibs-dev@jakarta.apache.org by ma...@apache.org on 2004/01/29 06:19:26 UTC
cvs commit: jakarta-taglibs/mailer/xml intro.xml mailer.xml
martinc 2004/01/28 21:19:26
Modified: mailer/src/org/apache/taglibs/mailer MailTag.java
mailer/xml intro.xml mailer.xml
Added: mailer/src/org/apache/taglibs/mailer PortTag.java
Log:
Add a new 'port' attribute to the <mail> tag, and a new <port> tag, to
allow the specification of a non-standard SMTP port.
PR: 23438
Submitted by: Dimitri (ochkarik at inbox.ru)
Revision Changes Path
1.10 +40 -3 jakarta-taglibs/mailer/src/org/apache/taglibs/mailer/MailTag.java
Index: MailTag.java
===================================================================
RCS file: /home/cvs/jakarta-taglibs/mailer/src/org/apache/taglibs/mailer/MailTag.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- MailTag.java 31 Oct 2002 05:01:27 -0000 1.9
+++ MailTag.java 29 Jan 2004 05:19:26 -0000 1.10
@@ -119,6 +119,11 @@
* <rtexprvalue>false</rtexprvalue>
* </attribute>
* <attribute>
+ * <name>port</name>
+ * <required>false</required>
+ * <rtexprvalue>false</rtexprvalue>
+ * </attribute>
+ * <attribute>
* <name>session</name>
* <required>false</required>
* <rtexprvalue>false</rtexprvalue>
@@ -199,6 +204,12 @@
private String reset_server = null;
/**
+ * provide the server port here for a new session
+ */
+ private String port = "25";
+ private String reset_port = null;
+
+ /**
* can be "text" or "html" (otherwise text is default)
*/
private String type = "text/plain";
@@ -295,6 +306,7 @@
reset_replyto = null;
reset_subject = null;
reset_server = null;
+ reset_port = null;
name.clear();
value.clear();
bodyparts.clear();
@@ -383,6 +395,12 @@
} else {
props.put("mail.smtp.host", server);
}
+ // set port to server
+ if (reset_port != null) {
+ props.put("mail.smtp.port", reset_port);
+ } else {
+ props.put("mail.smtp.port", port);
+ }
// set properties to deal will SendFailedExceptions
// send to all legal addresses
props.put("mail.smtp.sendpartial", "true");
@@ -698,6 +716,16 @@
}
/**
+ * set the server port to be used for the mail session
+ *
+ * @param value string that is the server port to be used
+ *
+ */
+ public final void setPort(String value) {
+ port = value;
+ }
+
+ /**
* set the jndi named session to be used to find the mail session
*
* @param value string that is the jndi named session
@@ -847,6 +875,15 @@
*/
protected final void resetServer(String value) {
reset_server = value;
+ }
+
+ /**
+ * reset the SMTP server port
+ *
+ * @param value string that is SMTP server port
+ */
+ protected final void resetPort(String value) {
+ reset_port = value;
}
}
1.1 jakarta-taglibs/mailer/src/org/apache/taglibs/mailer/PortTag.java
Index: PortTag.java
===================================================================
/*
* $Header: /home/cvs/jakarta-taglibs/mailer/src/org/apache/taglibs/mailer/PortTag.java,v 1.1 2004/01/29 05:19:26 martinc Exp $
* $Revision: 1.1 $
* $Date: 2004/01/29 05:19:26 $
*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.taglibs.mailer;
import java.util.*;
import javax.servlet.jsp.*;
import javax.servlet.jsp.tagext.*;
/**
* PortTag - JSP tag <b>port</b> is used for dynamically setting the mail
* server port that is going to be used to send the mail. The tag
* must be nested within a <b>mail</b> tag.
*
* <p>
* JSP Tag Lib Descriptor
* <p><pre>
* <name>port</name>
* <tagclass>org.apache.taglibs.mailer.PortTag</tagclass>
* <bodycontent>JSP</bodycontent>
* <info>
* Sets the mail server port used to send the mail
* </info>
* </pre></p></p>
*
* @author Rich Catlett
* @author Martin Cooper
*
* @version 1.0
*
*/
public class PortTag extends BodyTagSupport {
/**
* implementation of the method from the tag interface that tells the JSP
* page what to do after the body of this tag
*
* @throws JSPException thrown when an error occurs while processing the
* body of this method
*
* @return SKIP_BODY int telling the tag handler to not evaluate the body
* of this tag again
*
*/
public final int doAfterBody() throws JspException {
// parent tag must be a MailTag, gives access to methods in parent
MailTag myparent = (MailTag)findAncestorWithClass(this, MailTag.class);
if (myparent == null) {
throw new JspException("port tag not nested within mail tag");
}
BodyContent body = getBodyContent();
String port = body.getString();
// Clear the body since we only used it as input for the email address
body.clearBody();
if (port != null) {
port.trim();
if (port.length() > 0) {
myparent.resetPort(port); // set port in the parent tag
return SKIP_BODY;
}
}
throw new JspException("The port tag is empty");
}
}
1.10 +5 -0 jakarta-taglibs/mailer/xml/intro.xml
Index: intro.xml
===================================================================
RCS file: /home/cvs/jakarta-taglibs/mailer/xml/intro.xml,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- intro.xml 6 Feb 2003 01:54:40 -0000 1.9
+++ intro.xml 29 Jan 2004 05:19:26 -0000 1.10
@@ -17,6 +17,10 @@
<section name="News" href="News">
<news>
+ <newsitem date="01/26/2004">
+ The nightly build now includes a Port tag for setting the SMTP port
+ dynamically.
+ </newsitem>
<newsitem date="12/1/2002">
Version 1.1 Released
</newsitem>
@@ -84,6 +88,7 @@
<ul>
<li>Rich Catlett</li>
+ <li>Martin Cooper</li>
</ul>
</section>
1.12 +39 -0 jakarta-taglibs/mailer/xml/mailer.xml
Index: mailer.xml
===================================================================
RCS file: /home/cvs/jakarta-taglibs/mailer/xml/mailer.xml,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- mailer.xml 11 Nov 2003 05:32:11 -0000 1.11
+++ mailer.xml 29 Jan 2004 05:19:26 -0000 1.12
@@ -376,6 +376,45 @@
</tag>
<tag>
+ <name>port</name>
+ <tag-class>org.apache.taglibs.mailer.PortTag</tag-class>
+ <body-content>JSP</body-content>
+ <display-name>port</display-name>
+
+ <description>
+ Used to set the mail server port that will be used to send the mail.
+ </description>
+
+ <summary>
+ Used to set the mail server port that will be used to send the mail.
+ </summary>
+ <availability>1.1</availability>
+ <restrictions>
+ Must be nested within a mail tag.<br/>Must occur before send tag.
+ </restrictions>
+
+ <example>
+ <usage>
+ <comment>
+ Send a basic message: set the to, from, and subject attributes.
+ Set the server with the ServerTag, and port with PortTag.
+ </comment>
+ <code>
+<![CDATA[
+<mt:mail to="foo@home.net" from="bar@home.net" subject="mail taglib">
+ <mt:server>some.mailserver.com</mt:server>
+ <mt:port>26</mt:port>
+ <mt:message>[body of message]</mt:message>
+ <mt:send/>
+</mt:mail>
+]]>
+ </code>
+ </usage>
+ </example>
+
+ </tag>
+
+ <tag>
<name>message</name>
<tag-class>org.apache.taglibs.mailer.MessageTag</tag-class>
<body-content>JSP</body-content>
---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-dev-help@jakarta.apache.org