You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ofbiz.apache.org by "Jacques Le Roux (JIRA)" <ji...@apache.org> on 2007/12/09 01:22:43 UTC

[jira] Commented: (OFBIZ-1256) Send mail through gmail with the javamail api in ofbiz

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

Jacques Le Roux commented on OFBIZ-1256:
----------------------------------------

I would like to commit this patch if nobody see troubles in it

> 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
>    Affects Versions: SVN trunk
>         Environment: All
>            Reporter: Fabien Carrion
>            Assignee: Jacques Le Roux
>            Priority: Minor
>             Fix For: SVN trunk
>
>         Attachments: emailssl_diff.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.