Highlighted

"Local" or Accessible backup of cfmail emails

New Here ,
May 01, 2019

Copy link to clipboard

Copied

I'm a bit out of my league on this issue.

due to a recent infrastructure change that disabled the mail relay without actually notifying of an error and left us not sending any emails for two weeks, Worse we were completely unable to rebuild the "lost" emails. I've been tasked with a way to create a local backup of all outgoing mail.  This is easy enough to do in CF, however the team wants solutions that don't use CF tags.  The specific requirements I have are either to capture and locally store the cfmail file itself, or to capture the to, from, reply, cc, bcc, subject and body using (for instance) event gateways, mail log,or any listeners or apis that might be available.

The email log contains to, from and subject, but doesn't contain body, so it's not viable for us unless i am missing a setting that makes the log keep the body of the email.

I'm currently researching CFMailgun, and the Mailgun API, but i need a few other options as it does have some issues that may not be palatable to the client.

Can anybody point me to gateways, listeners or mail log settings that might meet my requirements?

Thank you.

Adobe Community Professional
Correct answer by Charlie Arehart | Adobe Community Professional

I hear where all this is going (have read the back and forth).

Miki, I don't know that there's a satisfactory solution, at least not from a CF perspective. There may be, from a mail SERVER perspective. Let me elaborate.

!) To be clear: no, there is no mechanism in CF that creates a backup of emails sent. The only mechanism to track mails sent is the mailsent.log, which as you know does NOT have the mail body.

I understand your folks are hoping there MAY be something that COULD do this, but there is nothing built-in to CF.

2) And sure, we might propose "well, you could generate the email content in a CFSAVECONTENT and save it off to a DB before passing it into a CFMAIL", but you're making it clear that your people don't want you to do "any code changes", and instead they think there should be SOME solution that will instead automatically save off the mail BEFORE sending. Again, there is no such feature in CF. (I realize that doing a code-based change would be complicated if you send email from many places in your app.)

And since CF's mail mechanism is not based on some 3rd party project or Tomcat library, we can't look to anything else to do it.

3) Someone might think, "couldn't we have something catch the files once added to the spool, to save them off". And perhaps you can, via some 3rd party tool. Just beware that it needs to  do the job only when the file is FINISHED being created, so as not to grab it WHILE being created. (For instance, the old directorywatcher event gateway added in CF7 doesn't do a good job in that regard.) Also, you will be fighting the spool mechanism that will be grabbing and sending off emails--perhaps faster than you can first "Save off a copy".

This just seems a bad idea to even try, but maybe you or someone else will think of some other solution that MAY suffice.

4) I would have proposed that you turn your attention to the mail server that CF is sending THROUGH (whatever is in the server field of the CF Admin mail page, or on the SERVER attribute of CFMAIL). It may be possible that THAT would offer an option for IT to save a backup of mails that IT is sending on your behalf. If you told us what kind of server that was, we might help find if it's possible.

But I know you keep saying you can't get access to "the relay", by which I assume you mean "the mail server" (which is "relaying" the email from CF to the destination recipients). If so, fair enough. YOU can't access it. Can ANYONE IN YOUR ORG? Maybe THEY can solve this problem, instead of you.

5) Along those same lines, though, you are wondering about changing to an alternative mail server like mailgun. Well, that won't help with making it more possible for "CF to make a backup", as the mail WILL STILL LEAVE CF. But again it MAY well be that it (or any of many alternative mail server software or services) WOULD be able to make a backup of all email THEY send (on your behalf).

I really think that's where you should be looking: at the MAIL SERVER. Indeed, most mail servers have a mechanism built-in ALREADY to backup mail they cannot deliver, just like CF's undelivr folder. I hear you saying that perhaps you/they can't access that. OK, fair enough. Get a mail server that WILL let you, sure.

And if your people think that's still not the right solution, and they want something done "on the cf server", share these thoughts we have all shared. At least they'll know that you are not alone in struggling to find an alternative (if, again, saving off a copy in code is not an option).

Let us know how it goes.

Views

642

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

"Local" or Accessible backup of cfmail emails

New Here ,
May 01, 2019

Copy link to clipboard

Copied

I'm a bit out of my league on this issue.

due to a recent infrastructure change that disabled the mail relay without actually notifying of an error and left us not sending any emails for two weeks, Worse we were completely unable to rebuild the "lost" emails. I've been tasked with a way to create a local backup of all outgoing mail.  This is easy enough to do in CF, however the team wants solutions that don't use CF tags.  The specific requirements I have are either to capture and locally store the cfmail file itself, or to capture the to, from, reply, cc, bcc, subject and body using (for instance) event gateways, mail log,or any listeners or apis that might be available.

The email log contains to, from and subject, but doesn't contain body, so it's not viable for us unless i am missing a setting that makes the log keep the body of the email.

I'm currently researching CFMailgun, and the Mailgun API, but i need a few other options as it does have some issues that may not be palatable to the client.

Can anybody point me to gateways, listeners or mail log settings that might meet my requirements?

Thank you.

Adobe Community Professional
Correct answer by Charlie Arehart | Adobe Community Professional

I hear where all this is going (have read the back and forth).

Miki, I don't know that there's a satisfactory solution, at least not from a CF perspective. There may be, from a mail SERVER perspective. Let me elaborate.

!) To be clear: no, there is no mechanism in CF that creates a backup of emails sent. The only mechanism to track mails sent is the mailsent.log, which as you know does NOT have the mail body.

I understand your folks are hoping there MAY be something that COULD do this, but there is nothing built-in to CF.

2) And sure, we might propose "well, you could generate the email content in a CFSAVECONTENT and save it off to a DB before passing it into a CFMAIL", but you're making it clear that your people don't want you to do "any code changes", and instead they think there should be SOME solution that will instead automatically save off the mail BEFORE sending. Again, there is no such feature in CF. (I realize that doing a code-based change would be complicated if you send email from many places in your app.)

And since CF's mail mechanism is not based on some 3rd party project or Tomcat library, we can't look to anything else to do it.

3) Someone might think, "couldn't we have something catch the files once added to the spool, to save them off". And perhaps you can, via some 3rd party tool. Just beware that it needs to  do the job only when the file is FINISHED being created, so as not to grab it WHILE being created. (For instance, the old directorywatcher event gateway added in CF7 doesn't do a good job in that regard.) Also, you will be fighting the spool mechanism that will be grabbing and sending off emails--perhaps faster than you can first "Save off a copy".

This just seems a bad idea to even try, but maybe you or someone else will think of some other solution that MAY suffice.

4) I would have proposed that you turn your attention to the mail server that CF is sending THROUGH (whatever is in the server field of the CF Admin mail page, or on the SERVER attribute of CFMAIL). It may be possible that THAT would offer an option for IT to save a backup of mails that IT is sending on your behalf. If you told us what kind of server that was, we might help find if it's possible.

But I know you keep saying you can't get access to "the relay", by which I assume you mean "the mail server" (which is "relaying" the email from CF to the destination recipients). If so, fair enough. YOU can't access it. Can ANYONE IN YOUR ORG? Maybe THEY can solve this problem, instead of you.

5) Along those same lines, though, you are wondering about changing to an alternative mail server like mailgun. Well, that won't help with making it more possible for "CF to make a backup", as the mail WILL STILL LEAVE CF. But again it MAY well be that it (or any of many alternative mail server software or services) WOULD be able to make a backup of all email THEY send (on your behalf).

I really think that's where you should be looking: at the MAIL SERVER. Indeed, most mail servers have a mechanism built-in ALREADY to backup mail they cannot deliver, just like CF's undelivr folder. I hear you saying that perhaps you/they can't access that. OK, fair enough. Get a mail server that WILL let you, sure.

And if your people think that's still not the right solution, and they want something done "on the cf server", share these thoughts we have all shared. At least they'll know that you are not alone in struggling to find an alternative (if, again, saving off a copy in code is not an option).

Let us know how it goes.

Views

643

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
May 01, 2019 0
LEGEND ,
May 01, 2019

Copy link to clipboard

Copied

Has this completely disabled the _sending_ of the email, or the creation of the email?  If not, then check the Undelivered directory to see if those lost emails are still there.

The easiest solution would be to BCC to a local address for future emails going out, that way you'll always have a backup copy of the email sent, without CF tags.

HTH,

^ _ ^

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
May 01, 2019 0
Adobe Community Professional ,
May 02, 2019

Copy link to clipboard

Copied

miki wrote

due to a recent infrastructure change that disabled the mail relay without actually notifying of an error and left us not sending any emails for two weeks, Worse we were completely unable to rebuild the "lost" emails.

Could you please explain what you mean by "lost"? Normally, e-mail seldom gets lost.

This is easy enough to do in CF, however the team wants solutions that don't use CF tags.

I don't understand. Do you no longer wish to use ColdFusion to send e-mail and, hence, are looking for an alternative? Or, do you intend to continue using ColdFusion to send, but are looking for a separate tool to log the mail?

The specific requirements I have are either to capture and locally store the cfmail file itself, ...

ColdFusion does that already anyway. As WolfShade said earlier, if ColdFusion is unable to send an e-mail, then all the details of the e-mail will be stored locally. The storage location is the directory {CF_INSTANCE_DIR}/Mail/Undelivr.

... to capture the to, from, reply, cc, bcc, subject and body using (for instance) event gateways, mail log,or any listeners or apis that might be available.

...

I'm currently researching CFMailgun, and the Mailgun API, but i need a few other options as it does have some issues that may not be palatable to the client.

An extra tool on top of ColdFusion mail? If so, wont it mean the addition of unnecessary functionality?

Suggestion for solution:

Just add something like this before your ColdFusion cfmail code,

<cfset email=structNew()>

<cfset email={to="#to_email_address#", from="#from_email_address#", subject="#email_subject#", body="#email_body#"}>

<cflog text="#serializeJSON(email)#" file="emailMessage">

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
May 02, 2019 2
Adobe Community Professional ,
May 02, 2019

Copy link to clipboard

Copied

This is probably not relevant to the original message and your response, but email gets lost all the time. I've been working as a mail server administrator for many years, and I see this happening regularly. All it takes is for the receiving mail server to accept the mail but not to deliver it. This is a common approach for handling spam, and it's called a "black hole". Of course, it's up to the receiving mail server to decide what is really spam and what isn't and this is done using algorithms, not manually. Usually, it just "disappears" the worst of the spam that you might receive, but ... that's usually. I can go to my mail log every day and see there were messages received and then discarded, and I can't get to those messages. If you're using a third-party product to perform mail filtering, you'll be able to see the same thing.

Also, if you're using a mail relay that isn't actively maintained, that relay might do any number of things with messages it can't deliver for whatever reason. That's a more likely problem here, I guess.

Dave Watts, Eidolon LLC

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
May 02, 2019 1
Adobe Community Professional ,
May 02, 2019

Copy link to clipboard

Copied

Hi Dave Watts​, I think you and I are looking at this from two different viewpoints. You from the path and eventual destination of the e-mail, I from its starting point.

I do agree with your arguments about e-mail getting lost en route or at the receiving mail server. However, I understood the question to be about the starting point. That is, about ColdFusion's handling of e-mail.

If you configure ColdFusion correctly to send e-mail, e-mail will seldom get lost. When an attempt fails, the e-mail message normally ends up in the Undelivr folder.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
May 02, 2019 0
LEGEND ,
May 02, 2019

Copy link to clipboard

Copied

I, also, believe the OP was referring to the email not properly starting; either not being generated, or failing to actually be sent.

But it wouldn't be the first time my assessment was not correct.

V/r,

^ _ ^

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
May 02, 2019 1
Adobe Community Professional ,
May 02, 2019

Copy link to clipboard

Copied

I definitely agree with that, as long as spooling is enabled. I don't really know what happens if spooling isn't enabled there.

Dave Watts, Eidolon LLC

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
May 02, 2019 1
New Here ,
May 15, 2019

Copy link to clipboard

Copied

I was away too long apparently.  I'll try to answer the questions, let me know if i missed any

1. define lost.

the emails went to the spool folder, were piked up by the relay but the relay was partially decommissioned, and while we were given the relay "logs" access to the relay itself was not granted.  From the server perspective, the emails were sent, but never got to the recipients.  They went somewhere, but nowhere we can go after them.

They are not in UNDELIVR folder because they were picked up by the relay before disappearing.  As far as CF can tell, they were sent

2. are we trying to use something different to send email?

No.  Not unless we have to. We need to put copies of the emails somewhere where we can access them after they leave the server because this is likely to happen again.

We need to back up every email we send either by keeping a copy of the cfmail file somewhere OR by putting to, from subject and body in a database OR by doing something that we can use in the future to REBUILD the emails delivered to the relay.

3. CF does it already? 

ONLY if the email is not deliverable.  As I understand it, If the relay takes it from the spool folder, it is gone. Am i wrong? Does it go to a "sent" folder somewhere on the CF server?  Is there a way to add the body to the mail log? That would allow us to rebuild an email from the mail log? 

4. question is about starting point.

kind of.  Spooling is enabled, the mail goes out every however many seconds emailing is happening, but when the relay is partially decommissioned, even sending to a local email doesn't happen. 

Conclusion

@Dave Watts summed it up but unlike him, we are not being granted access to the relay.  In order to rebuild emails if this happens again, we need a local backup.  I will try his suggestion and add it to the possible solutions, but am looking specifically for things we can do that do not use coldfusion tags or change cf code.  I proposed three cold fusion based solutions and they were POSITIVE i could find something that would not mean changing the code.  I'm glad they think so highly of me but they are kind-of wrong.

Other than MailGun, can you recommend APIs, gateways, listeners or mail log settings that might deliver what we're trying to do?  For instance, could i intercept the call to the java listener from cf and create a copy that way?  Or ?

Thanks for being so helpful, i really need to remember to come back more often.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
May 15, 2019 0
Adobe Community Professional ,
May 15, 2019

Copy link to clipboard

Copied

miki  wrote

2. are we trying to use something different to send email?

...We need to put copies of the emails somewhere where we can access them after they leave the server because this is likely to happen again.

We need to back up every email we send either by keeping a copy of the cfmail file somewhere OR by putting to, from subject and body in a database OR by doing something that we can use in the future to REBUILD the emails delivered to the relay.

You could simply log each e-mail message (before ColdFusion sends it). See my suggestion earlier.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
May 15, 2019 1
Adobe Community Professional ,
May 17, 2019

Copy link to clipboard

Copied

I hear where all this is going (have read the back and forth).

Miki, I don't know that there's a satisfactory solution, at least not from a CF perspective. There may be, from a mail SERVER perspective. Let me elaborate.

!) To be clear: no, there is no mechanism in CF that creates a backup of emails sent. The only mechanism to track mails sent is the mailsent.log, which as you know does NOT have the mail body.

I understand your folks are hoping there MAY be something that COULD do this, but there is nothing built-in to CF.

2) And sure, we might propose "well, you could generate the email content in a CFSAVECONTENT and save it off to a DB before passing it into a CFMAIL", but you're making it clear that your people don't want you to do "any code changes", and instead they think there should be SOME solution that will instead automatically save off the mail BEFORE sending. Again, there is no such feature in CF. (I realize that doing a code-based change would be complicated if you send email from many places in your app.)

And since CF's mail mechanism is not based on some 3rd party project or Tomcat library, we can't look to anything else to do it.

3) Someone might think, "couldn't we have something catch the files once added to the spool, to save them off". And perhaps you can, via some 3rd party tool. Just beware that it needs to  do the job only when the file is FINISHED being created, so as not to grab it WHILE being created. (For instance, the old directorywatcher event gateway added in CF7 doesn't do a good job in that regard.) Also, you will be fighting the spool mechanism that will be grabbing and sending off emails--perhaps faster than you can first "Save off a copy".

This just seems a bad idea to even try, but maybe you or someone else will think of some other solution that MAY suffice.

4) I would have proposed that you turn your attention to the mail server that CF is sending THROUGH (whatever is in the server field of the CF Admin mail page, or on the SERVER attribute of CFMAIL). It may be possible that THAT would offer an option for IT to save a backup of mails that IT is sending on your behalf. If you told us what kind of server that was, we might help find if it's possible.

But I know you keep saying you can't get access to "the relay", by which I assume you mean "the mail server" (which is "relaying" the email from CF to the destination recipients). If so, fair enough. YOU can't access it. Can ANYONE IN YOUR ORG? Maybe THEY can solve this problem, instead of you.

5) Along those same lines, though, you are wondering about changing to an alternative mail server like mailgun. Well, that won't help with making it more possible for "CF to make a backup", as the mail WILL STILL LEAVE CF. But again it MAY well be that it (or any of many alternative mail server software or services) WOULD be able to make a backup of all email THEY send (on your behalf).

I really think that's where you should be looking: at the MAIL SERVER. Indeed, most mail servers have a mechanism built-in ALREADY to backup mail they cannot deliver, just like CF's undelivr folder. I hear you saying that perhaps you/they can't access that. OK, fair enough. Get a mail server that WILL let you, sure.

And if your people think that's still not the right solution, and they want something done "on the cf server", share these thoughts we have all shared. At least they'll know that you are not alone in struggling to find an alternative (if, again, saving off a copy in code is not an option).

Let us know how it goes.

/Charlie (server troubleshooter, carehart.org)

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
May 17, 2019 0
New Here ,
May 17, 2019

Copy link to clipboard

Copied

Thanks BKBK​ and Charlie.

This is the information i needed to go back to them and suggest that a Code solution would be better. (Lots of work, but better)

I am adding BKBK's really awesome suggestion to the code solutions i suggested already and hopefully having the information i gave them reiterated by somebody with an ACP, MVP and who has been around the block several times might get them to see it my way. 

I suspect because i'm just a "coder" not a "engineer" and still find OO a little foreign, they ignore the fact that I've been dealing with ColdFusion off and on since version 3. 

But since when i hear "Listeners" and "Gateways" I translate it to "Stuff Miki Knows little or nothing about" i had to check.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
May 17, 2019 0
LEGEND ,
May 17, 2019

Copy link to clipboard

Copied

miki  wrote

I suspect because i'm just a "coder" not a "engineer" ..

Some would argue that a "coder" is a "software engineer".  Matter of fact, the company I work for lists my professional title as "Software Engineer I".  So..

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
May 17, 2019 0