ColdFusion Muse

email connection crossover workarounds

Mark Kruger August 22, 2013 5:04 PM ColdFusion, Coldfusion Troubleshooting Comments (1)

As a follow up to yesterday's post (regarding sending mail and having it end up in someone else's "sent" folder) I thought I might put some flesh on the workaround suggested both in the bug report and on CF-Talk. The suggestion is to:

Create a CNAME to point to the SMTP server address so that both websites were looking at different domain names.
This idea is workable up to a point so I thought I would explore it for my readers.

A "CNAME" record is a DNS entry that functions as an alias. When a DNS server sees a CNAME it says "Oh.. the user wanted abc.com but is see that's just a pointer to xyz.com. I'll serve up xyz.com's IP address." What the workaround suggests is that such an alias can be created to "fool" the ColdFusion server into believing that connection A is different from connection B even though they are pointed at the same IP address.

To return to our example of Bob and Mary - if Bob's email is relayed to smtp.bobsadufas.com (with a CNAME record that aliases smtp.bobsadufas.com to smtp.gmail.com) and Mary's email is relayed to smtp.ithinkbobsadufas.com (with a CNAME record that aliases smtp.ithinkbobsadufas.com to smtp.gmail.com) then the ColdFusion server would assume that both emails required a separate SMTP connection - even though in reality they are hitting the exact same mail server relay. ColdFusion sees them as different because it's pool of connections is not tied to the IP address but to the domain string - so no crossover is possible.

This will work to a point. But there's a bit more to it than simply creating a CNAME and calling it good. For example, what if the two emails are on the same domain? If both bob and Mary are relaying through smtp.bobsadufas.com then a crossover is still possible right? Indeed each email address used on the server that is required relay through smtp.gmail.com is actually going to require its own CNAME just to be safe. Needless to say that's an untenable solution in many cases.

In addition you will need to modify the code. This is not clear in the workaround description. Each cfmail tag that specifies server="smtp.gmail.com" is going to have to be updated with the string representing the CNAME - that's the only way ColdFusion will know which connection to use (or not use). So all around this is an iffy solution to a ticklish problem. A more reliable work around (where possible) is to use a relay on a server that does not place the email in the sent folder - like a local SMTP server. Meanwhile this is an ongoing issue.

  • Share:

1 Comments

  • snake's Gravatar
    Posted By
    snake | 8/22/13 6:32 PM
    In general if you are relaying mail through your website it is best to have mailbox setup specifically for that purpose rather than use personal mailboxes, then you wont have the issue you mentioned and is a lot easier than have a different sub-domain CNAME record name for every single user.