[ 
https://issues.apache.org/jira/browse/OFBIZ-1256?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12553901
 ] 

Chris Howe commented on OFBIZ-1256:
-----------------------------------

First, good job Fabien!

Four minor things on this
1)port = UtilProperties.getPropertyValue("general.properties", 
"mail.smtp.port", "25"); 
   this should not have a default value.  While smtp's default port is indeed 
25, the default value should remain handled by the Transport

2)ssl = UtilProperties.getPropertyValue("general.properties", "mail.smtp.ssl", 
"javax.net.ssl.SSLSocketFactory"); 
   this should not have a default value.  While this is the default ssl socket 
for JavaMail currently, we need to allow JavaMail to set this in the event of 
an improvement or change.

maybe:
3)props.put("mail.smtp.socketFactory.port", port); 
   Since JavaMail considers mail.smtp.socketFactory.port and mail.smtp.port as 
separate variables, perhaps we should as well

maybe:
4)http://www.javaworld.com/javatips/jw-javatip115.html claims that we need to 
add a provider :
  Security.addProvider( new com.sun.net.ssl.internal.ssl.Provider()); to the 
java security or add it dynamically in this method.  I don't know if we already 
have it included through the other things going on in OFBiz, but we may want to 
add it again here dynamically. 

I'm attaching the diff to general.properties that would be required if these 
four points are considered

> Send mail through gmail with the javamail api in ofbiz
> ------------------------------------------------------
>
>                 Key: OFBIZ-1256
>                 URL: https://issues.apache.org/jira/browse/OFBIZ-1256
>             Project: OFBiz
>          Issue Type: New Feature
>          Components: content
>    Affects Versions: SVN trunk
>         Environment: All
>            Reporter: Fabien Carrion
>            Assignee: Jacques Le Roux
>            Priority: Minor
>             Fix For: SVN trunk
>
>         Attachments: emailssl_diff.patch, gmail.patch
>
>
> This a small patch to accept ssl connections to smtp servers.
> Index: content/src/org/ofbiz/content/email/EmailServices.java
> ===================================================================
> --- content/src/org/ofbiz/content/email/EmailServices.java      (revision 
> 576503)
> +++ content/src/org/ofbiz/content/email/EmailServices.java      (working copy)
> @@ -129,6 +129,8 @@
>  
>          String sendFrom = (String) context.get("sendFrom");
>          String sendType = (String) context.get("sendType");
> +        String port = (String) context.get("port");
> +        String ssl = (String) context.get("ssl");
>          String sendVia = (String) context.get("sendVia");
>          String authUser = (String) context.get("authUser");
>          String authPass = (String) context.get("authPass");
> @@ -151,6 +153,12 @@
>              if (authUser != null && authUser.length() > 0) {
>                  useSmtpAuth = true;
>              }
> +            if (port == null || port.length() == 0) {
> +                port = UtilProperties.getPropertyValue("general.properties", 
> "mail.smtp.port", "25");
> +            }
> +            if (ssl == null || ssl.length() == 0) {
> +                ssl = UtilProperties.getPropertyValue("general.properties", 
> "mail.smtp.ssl", "javax.net.ssl.SSLSocketFactory");
> +            }
>          } else if (sendVia == null) {
>              return ServiceUtil.returnError("Parameter sendVia is required 
> when sendType is not mail.smtp.host");
>          }
> @@ -168,6 +176,14 @@
>          try {
>              Properties props = System.getProperties();
>              props.put(sendType, sendVia);
> +           if (port != null && port.length() > 0) {
> +               props.put("mail.smtp.port", port);
> +               props.put("mail.smtp.socketFactory.port", port);
> +           }
> +           if (ssl != null && ssl.length() > 0) {
> +               props.put("mail.smtp.socketFactory.class", ssl);
> +               props.put("mail.smtp.socketFactory.fallback", "false");
> +           }
>              if (useSmtpAuth) {
>                  props.put("mail.smtp.auth", "true");
>              }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to