Defining and Using Multiple SMTP Servers

166 views
Skip to first unread message

Juan Aguilar

unread,
Oct 22, 2015, 2:36:54 PM10/22/15
to Lucee
It's been a while since I had to define more than one mail server on my Cold Fusion server. My recollection (from way, way, back) is that, if I defined the servers in the administrator, I should be able to use server="server name" as a cfmail attribute and that mail would go out using the selected server (and the associated credentials in the administrator).

However, it appears that, if I use the server attribute in the code, I also have to define a username and password, which would defeat the purpose of defining the servers in the administrator.

The administrator says:

You can define more than one mail server. When sending an email, Lucee tries to send the mail with the first defined mail server. If the send operation fails, Lucee will continue using the next mail server in the list.

Am I mistaken about how to use multiple SMTP servers in Lucee? If I want to use a specific SMTP server in my code, do I have to define the server, username, and password, too?

Thanks.

Terry Whitney

unread,
Oct 22, 2015, 2:54:13 PM10/22/15
to Lucee
The tag CFMAIL supports server, so you could have a condition that chooses the server. 

You could use a smart host or define AAA records and point to a server cluster for your external mail


Far as I remember you can setup a different connector per instance, though it seems cleaner from a sys admin stand point, its usually easier from a programming stand point to just define the mail server in the Application.cfc 

Juan Aguilar

unread,
Oct 22, 2015, 3:44:57 PM10/22/15
to Lucee
Bit of a different use case.

I'd like to use one SMTP server for external e-mails and another for internal e-mails. I thought I could do the following:

<cfmail to="exte...@example.com" from="sup...@website.com" subject="Your Order" server="externalmail.website.com">

and 

<cfmail to="inte...@example.com" from="sup...@website.com" subject="Internal Support Ticket" server="internalmail.website.com">

Both externalmail.website.com and internalmail.website.com are set and verified in the administrator, with externalmail listed first.

Now, if I send mail without the server attribute, it all gets sent via externalmail.website.com. I expect that. 

But, both of the cases above fail. The /WEB-INF/lucee/remote-client/open/*.tsk file is harder to read but I definitely see:

530 Authentication required

which suggests to me that the cfmail tag is not picking up the administrator credentials when the server attribute is set. This may be how cfmail works in Lucee and I have a very old memory of how the tag used to work.

In order for the above to work, I would have to set the username and password attributes in the code, which I am trying to avoid, if possible.

Terry Whitney

unread,
Oct 23, 2015, 9:46:51 AM10/23/15
to Lucee
Without going into great details about you network setup.

What you are asking for is not a Lucee issue, but how you have your email server setup.

Go setup you inbound and outbound server(s) to allow access full access to the lucee host.

I would suggest, if you are new to this, just allow internal interfaces to communicate between the three in this manor to minimize any potential security risks.





On Thursday, October 22, 2015 at 2:36:54 PM UTC-4, Juan Aguilar wrote:
Message has been deleted

Juan Aguilar

unread,
Oct 23, 2015, 11:12:52 AM10/23/15
to Lucee
Thanks, Terry,

Unfortunately, this isn't a network security issue. Cold Fusion (the server, not the language) used to allow you to specify a server in the CFMAIL tag and, if that server was designated in the administrator, then it would use the credentials setup there to send the message.

Lucee also allows you to specify a server in the CFMAIL tag but does not cross-reference to see if that server is already setup in the administrator. Consequently, if you want to use different SMTP servers and those SMTP servers require authentication, then using the server attribute means you have to specify the username and password in the CFMAIL tag, too. Otherwise, you get the "530 Authentication required" response back from the SMTP server.

Since my preference would to not hardcode credentials, an enhancement request would be for Lucee to check to see if the SMTP server designated in the CFMAIL tag attribute is configured in the administrator prior to queueing the message and, if so, using the administrator credentials for SMTP authentication. I suppose a workaround would be to load the credentials through a variable instead.

Thanks again.

Dawesi

unread,
Nov 1, 2015, 11:07:22 PM11/1/15
to Lucee
I find the discrepancy of how mail servers can't have a name, but datasources can in CFML inconsistent also.

I've proposed messagesource and other message based implementations in the past also (for about 5 versions of CFML), however the powers to be at Adobe (some of which are now Lucee powers to be) were to narrow minded to take the server admin forward. all admins are stuck in 2005 IMHO.

Regards,
Chris Dawes

Dawesi

unread,
Nov 1, 2015, 11:09:55 PM11/1/15
to Lucee
Here is Adam Cameron's response  (just to reignite this as a real value add to the server)
Reply all
Reply to author
Forward
0 new messages