Hi Rishi,

Le 09/05/2018 à 11:12, Rishi Solanki a écrit :
Community, I think we should mention the SystemProperty where required in
Production Setup Guide or may be we can add version of production setup
guide which will tells user upto which release this production setup guide
will work. I know we discuss this kind of effort in past for all the
documents and we agree on some point. But this is quicker to manage
Production Setup Guide, if we agree then I can do it.
Yes good idea, a simple information for concerned versions in the current 
Production Setup Guide fits with me

Jacques

I'm fine with either change the existing one or maintain the version. But
first we should have one which works always with latest. Thanks!


Rishi Solanki
Sr Manager, Enterprise Software Development
HotWax Systems Pvt. Ltd.
Direct: +91-9893287847
http://www.hotwaxsystems.com
www.hotwax.co

On Wed, May 9, 2018 at 3:33 AM, [email protected] <[email protected]>
wrote:

Hello,

here is a problem with my e-mail base-configuration.

I configured email according to the setup guide:

https://cwiki.apache.org/confluence/display/OFBIZ/Apache+OFBiz+Technical+
Production+Setup+Guide#ApacheOFBizTechnicalProduction
SetupGuide-EmailServerSettings


Unfortunately no email seems to be sent from server
(the send email button in partymgr works fine now (thanks to Jacques!),
but no email reaches client). No error message, no error in log.

Also I tried to register in the ecommerce system and send
an "Forgot Your Password" email, but none of the emails were sent.

To get more info about the problem, I wrote a groovy script and copied
parts of the sendEmail-code from EmailServices.java.
The script below surprisingly works fine and sends emails!

So I don't understand, why OFBiz itself does not send mails.
Is there any further configuration necessary?



The script (which sends mails):

import javax.mail.Session;

import javax.activation.DataHandler;
import javax.activation.DataSource;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.SendFailedException;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeBodyPart;
import javax.mail.internet.MimeMessage;
import javax.mail.internet.MimeMultipart;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.stream.StreamSource;

import org.apache.fop.apps.Fop;
import org.apache.fop.apps.MimeConstants;
import org.apache.ofbiz.base.util.Debug;
import org.apache.ofbiz.base.util.GeneralException;
import org.apache.ofbiz.base.util.HttpClient;
import org.apache.ofbiz.base.util.HttpClientException;
import org.apache.ofbiz.base.util.UtilGenerics;
import org.apache.ofbiz.base.util.UtilMisc;
import org.apache.ofbiz.base.util.UtilProperties;
import org.apache.ofbiz.base.util.UtilValidate;
import org.apache.ofbiz.base.util.collections.MapStack;
import org.apache.ofbiz.base.util.string.FlexibleStringExpander;
import org.apache.ofbiz.entity.Delegator;
import org.apache.ofbiz.entity.GenericValue;
import org.apache.ofbiz.entity.util.EntityUtilProperties;
import org.apache.ofbiz.service.DispatchContext;
import org.apache.ofbiz.service.GenericServiceException;
import org.apache.ofbiz.service.LocalDispatcher;
import org.apache.ofbiz.service.ServiceUtil;
import org.apache.ofbiz.service.mail.MimeMessageWrapper;
import org.apache.ofbiz.webapp.view.ApacheFopWorker;
import org.apache.ofbiz.widget.renderer.macro.MacroScreenRenderer;
import org.apache.ofbiz.widget.renderer.ScreenRenderer;
import org.apache.ofbiz.widget.renderer.ScreenStringRenderer;
import org.xml.sax.SAXException;

def testMail() {
         sendType = "mail.smtp.host"
         sendVia = "smtp.myhost.com"
         Properties props = System.getProperties()
     props.put(sendType, sendVia)
     Session session
     session = Session.getInstance(props);
     MimeMessage mail
     mail = new MimeMessage(session);
         Transport trans = null
         sendFrom = "obfiz.example.com"
         sendTo = "[email protected]"
         subject = "testMail from OFBiz"
         mp = new MimeMultipart();

         MimeBodyPart mbp = new MimeBodyPart();
         mbp.setText("Content: a test mail from OFBiz system")

         mp.addBodyPart(mbp);
         mail.setContent(mp);

         mail.setFrom(new InternetAddress(sendFrom));
         mail.setSubject(subject, "UTF-8");
         mail.setHeader("X-Mailer", "Apache OFBiz, The Open For Business
Project");
         mail.setSentDate(new Date());
         mail.addRecipients(Message.RecipientType.TO, sendTo);

         trans = session.getTransport("smtp")
         authUser = UtilProperties.getPropertyValue('general.properties',
'mail.smtp.auth.user')
         authPass = UtilProperties.getPropertyValue('general.properties',
'mail.smtp.auth.password')

     trans.connect(sendVia, authUser, authPass);
         trans.sendMessage(mail, mail.getAllRecipients())
         trans.close()

         logWarning("successful run of testMail ")
         logWarning(" user = " + userLogin.partyId);

         return success("this test is done successful")
}


Reply via email to