0

In my project I am using <cfmail> to send an order confirmation to a user after successful creation of an order. I have got one doubt. If the mail server goes down during that time is there any way to handle that situation with cftry and cfcatch, or doesn't it handle those errors?

Community
  • 1
  • 1
user3427540
  • 1,162
  • 1
  • 14
  • 30
  • If the problem is with the mail server, what would you put in your cfcatch? – Dan Bracuk Jun 20 '14 at 12:42
  • @DanBracuk: I think we can log it somewhere, so that it will help us to detect whether the mail sent successfully or not? – user3427540 Jun 20 '14 at 12:47
  • Well at least you didn't say that you would have notified someone because that would have involved mail. However, if you can look at log files, you can also look at the contents of the spool and undeliverable files. That might involve less time and effort. – Dan Bracuk Jun 20 '14 at 13:38
  • @DanBracuk: Yes you are correct. Still just want to know is it a correct way to generate exception by adding `spoolenable=false` for generating exception when mail gets undelivered due to any reason? – user3427540 Jun 20 '14 at 13:45

1 Answers1

1

Normally if spoolenable is enabled the email will go to the spool and the page processes whether the mail actually gets sent or not as long as all the required fields are entered and valid.

https://wikidocs.adobe.com/wiki/display/coldfusionen/cfmail

Spool Enable details from Wiki

spoolenable Optional

Whether to spool mail or always send it Immediately. Overrides the ColdFusion Administrator Spool mail messages to disk for delivery setting.

yes: saves a copy of the message until the sending operation is complete. Pages that use this option might run slower than the ones that use the No option.

no: queues the message for sending, without storing a copy until the operation is complete. If a delivery error occurs when this option is No, ColdFusion generates an Application exception and logs the error to the mail.log file.

Randy Johnson
  • 349
  • 1
  • 9
  • So if my mail server is down and if i have `spoolenable=false`on cfmail, then i think it will throw exception , correct? – user3427540 Jun 20 '14 at 07:28
  • One thing to note is that when you do spool emails they may not send straight away. The emails will be added to a queue and sent periodically. – Will Jun 20 '14 at 08:09