Mail server configuration [solved]

I have been assisting with the migration of a Lucee 5.x based site from one hosting provider to another and mostly this has been trouble-free. I am not a Lucee expert, so please forgive my perhaps simple question.

When the site attempts to send an email, an exception is thrown indicating that no smtp servers have been configured. With the site having been migrated, I had expected the configuration to have been moved over.

I am not sure how to access the Luceee Administration page to check, so I added the mail server information to Application.cfc for the only context that I see to contain:

this.mails =[ {
             host: "smtp.gmail.com"
            ,port: 587
            ,username: "xxx@xxx"
            ,password: "xxx"
            ,ssl: false
            ,tls: true
            ,lifeTimespan: CreateTimeSpan( 0, 0, 1, 0 )
            ,idleTimespan: CreateTimeSpan( 0, 0, 0, 10 )
        } ];

The above text is within the “component” section. This is based on a forum post I found here. I also tried setting “mails” to “mailservers” as I found another post that suggested this be used. Neither has made no difference. I appreciate that the cfmail tag could be modified to include the necessary information, but I would prefer to have this in the global configuration.

I noticed that lucee-web.xml.cfm has an empty mail tag and am not sure if this is relevant?

So, can someone point me in the right direction with regard to accessing the Administration page? Also, is there a way of configuring the mail server settings without accessing this page? Where are the configuration settings actually stored and is it possible to change them manually on a global basis?

Thanks in advance.

You Need to store the SSL certificate for the smtp server in question on the local machine or inside the context of your application server (tomcat) so that you can connect.

Thanks for taking the time to reply, Terry. The OS certificate store already has this information present. I am able to use an application like mailx to send emails. The error message shown says nothing about certificate validation, it specifically says that no mail servers have been configured.

I am more specifically asking where the SMTP server information is set up, in the first instance.

Incidentally, modifying the cfmail tag itself works just fine. I am able to send emails. So, I just need to know how to set up the default mail server for the application.

Assuming yours is a standard Tomcat installation the server wide admin UI should be accessible at:

http://localhost:8888/lucee/admin/server.cfm?action=services.mail

I use

this.mailservers = [ { server details etc } ];

in each app’s Application.cfc and it’s working fine as the default (nothing defined in the admin UI). It’s a local, locked down mail server though so just a simple connection on port 25.

1 Like

Thanks Julian. Your feedback does confirm that what I have done should have worked. The installation appears to be slightly non-standard and I am wondering if this is related to the issue, since I have also tried as you suggested and the mail server info is not returned.

I have manged to navigate to the page in question. I do not know the password, but will see what I can do to find out what it is.

Having dug around the source files it definitely looks as though I am working on a Lucee 5.x installation but is there an easy way to confirm this? If for some reason the version is re 5.0, that would explain why the Application.cfm change does not work.

I have access to the pages now. Thanks Julian. Still would love to know why the Application.cfc did not work, but I am going to try just setting the defaults in the admin page.

Edit: Corrected type “cfm” to “cfc”

dump( server.lucee.version );

1 Like

Is that a typo? It would need to be Application.cfc

Yes, it’s a typo :slight_smile:

This is what the file looks like (with details masked for security):

component {
	this.name = "lucee_context#server.lucee.version#";
        this.clientmanagement="no";
        this.clientstorage="file";
        this.scriptprotect="all";
        this.sessionmanagement="yes";
        this.sessionStorage="memory";
        this.sessiontimeout="#createTimeSpan(0,0,30,0)#";
        this.setclientcookies="yes";
        this.setdomaincookies="no";
        this.applicationtimeout="#createTimeSpan(1,0,0,0)#";
        this.localmode="update";
        this.web.charset="utf-8";
        this.scopeCascading="strict";

        this.mailservers =[ {
             host: "xxxxx"
            ,port: 587
            ,username: "xxxxxxx"
            ,password: "xxxxxxx"
            ,ssl: false
            ,tls: true
            ,lifeTimespan: CreateTimeSpan( 0, 0, 1, 0 )
            ,idleTimespan: CreateTimeSpan( 0, 0, 0, 10 )
        } ];

}


Connecting to the admin panel shows that I am running 5.3.3.62, for your info.

Which version are you running? It would need to be 5.1.0.26 or later.

Should be working then. Might be worth filing a bug.

Having logged into the admin panel, it mentions that some patches are available, so I’ll see about installing them first and then do as you suggest. Did the above file look OK? Is there a way of having Lucee ignore or use the Application.cfc file? I wonder if it is disabled.

My version number above is incorrect. I need to read more carefully. It is 5.2.5.20 but it notes that the update is available to the version I mentioned. I’ll try this first.

Yes. Updating has had no effect. The error reported is:

lucee.runtime.exp.NativeException: no SMTP Server defined
 	at lucee.runtime.net.smtp.SMTPClient.send(SMTPClient.java:725)
 	at lucee.runtime.tag.Mail.doEndTag(Mail.java:582)
 	at messageposter_cfm$cf.call(/messagePoster.cfm:23)
 	at lucee.runtime.PageContextImpl._doInclude(PageContextImpl.java:942)
 	at lucee.runtime.PageContextImpl._doInclude(PageContextImpl.java:834)
 	at lucee.runtime.listener.ClassicAppListener._onRequest(ClassicAppListener.java:64)
 	at lucee.runtime.listener.MixedAppListener.onRequest(MixedAppListener.java:43)
 	at lucee.runtime.PageContextImpl.execute(PageContextImpl.java:2409)
 	at lucee.runtime.PageContextImpl._execute(PageContextImpl.java:2399)
 	at lucee.runtime.PageContextImpl.executeCFML(PageContextImpl.java:2374)
 	at lucee.runtime.engine.Request.exe(Request.java:43)
 	at lucee.runtime.engine.CFMLEngineImpl._service(CFMLEngineImpl.java:1109)
 	at lucee.runtime.engine.CFMLEngineImpl.serviceCFML(CFMLEngineImpl.java:1055)
 	at lucee.loader.engine.CFMLEngineWrapper.serviceCFML(CFMLEngineWrapper.java:102)
 	at lucee.loader.servlet.CFMLServlet.service(CFMLServlet.java:51)
 	at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
 	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:292)
 	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
 	at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
 	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
 	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
 	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212)
 	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
 	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
 	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141)
 	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
 	at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616)
 	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
 	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:528)
 	at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1099)
 	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:670)
 	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1520)
 	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1476)
 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
 	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
 	at java.lang.Thread.run(Thread.java:748)
 Caused by: lucee.runtime.net.mail.MailException: no SMTP Server defined

I wonder if the Application.cfc is being ignored or not being picked up. Where is the default usually located? The one I am working with is here: /webapps/ROOT/WEB-INF/lucee/context/Application.cfc

Try adding

dump( this );abort;

to your Application.cfc, below your this.mailservers definition and see if works.

1 Like

@mdsystems, Where is your Application.cfc located?

/webapps/ROOT/WEB-INF/lucee/context/Application.cfc is the only file I can locate.

And adding what Julian suggests does nothing, so I think it’s safe to conclude that it is not being referenced. How do I go about ensuring that it is referenced?

Please move the Application.cfc under the /webapps/root folder. Hope, this will work.

1 Like