How to see which mail server was used?

Adobe ColdFusion includes the mail server address in it’s mail log. Like “Mail:… was successfully sent using 10.1.1.1”. Is there a way to get this level of information from Lucee? I have more than one mail server defined in the admin, and for troubleshooting I sometimes need to know which mail server was used.

I’ve already set the mail loging level to “INFO”. I’ve also tried DEBUG and TRACE, those are no different from INFO.

By default lucee doesn’t do that, but you can use cflog for that or write your own output or
you can use cffile with append and create your own log file.

Thanks @Terry_Whitney. Sure I can manually do some logging, but how would I know which mail server Lucee used to deliver the mail?

Or are you suggesting rearchitecting our applications so that we store the mail server addresses/passwords/etc somewhere, then loop through the servers and try each one until successful? Then I would know which one was used and could log it?

@Ryan_Stille You could in your logging process, set something for mailserverX, so if you have multiple mail servers and / or multiple ColdFusion servers you can have better diagnostic logs.

As for the configuration, while there is no “right answer” to this, my configuration for the entire platform is stored in a database table. This way when I have an email job, it calls forth the correct mail server(s) based upon what is being sent.

I used to do exactly what you suggest, which is send one email at a time from Lucee / Coldfusion. This works well for small amounts of email and really beefy configurations. This however isn’t practical when it comes to scale.

Anything under 10K emails a day, CFMail from a local server properly configured is fine. Anything over 10K emails or anything that may grow over 10K emails, I suggest creating a dedicated email server and outputing what you need using CFFILE.

As for mailserver configuration, here is what I do.

For small jobs, personal items, ectra, yes I store and throw credentials at specialized sender code for lack of a better word. The code pulls from the database the mail server configuration, which includes passwords and application settings and then sends the message

For larger items, such as bulk mail and transactional emails on a non personal scale, I setup a dedicated vps for the purpose of sending email. Its literally 1000x more efficient in processing terms than anything you will have using java / ColdFusion based email.

I am sure there maybe a better way but this works for what I need

Instead of using CFmail I write the output to a file using cffile. The file is put in a specialized directory that is picked up by a cron job every few seconds and moves files to the correct “mail” server. The “Mail sever” could be anything from the transactional email such as a signup or invoice to a newsletter or internal email for a report, or a sms message. The “Mail” servers all have their own configuration files so security is at the OS and configuration level. This allows us to send 100K emails in the same time it would take us to send 1000 of the same emails.

I’ve created an incompatibility issue in Jira [LDEV-3839] - Lucee

2 Likes

@Ryan_Stille which log file did you change? I think it’s remoteclient.log rather than mail.log

@Zackster I had only tried setting the level to INFO on mail.log, but I just tried setting remoteclient.log to INFO - It logs that mail was successfully sent, but does not list which mail server was used.

"INFO","Thread-100529","01/25/2022","10:21:40","remote-client","successfully executed: my-test-email-subject-here"

And it actually logged it twice, which is odd. mail.log only lists it once, so I know I didn’t accidentally send it twice.