Coldfusion CFMAIL and sendgrid - coldfusion

I have 2 clients on the same server that I host, that both send email through sendgrid.com (both have their own accounts).
I was looking at reports on sendgrid and noticed that categories from "client 1" were showing up in a report for "client 2".
I spent extensive time on the phone with sendgrid and they are telling me that a handful of emails 65 from a batch of 3000 for "client 1" show as being sent through "client 2"'s authenticated user.
In my scripting, I use coldfusion cfmail and I specify the SMTP address, username and password for that client into the tag.
A possible theory takes into account the "Maintain connection to mail server" check box under mail in the administrator.
"Select this check box to keep the connection to a mail server open for reuse after delivering a message (recommended)."
If both clients send email at the same time (very much possible) would the coldfusion mail spooling engine separate them out based on server/username and password or send them all through to the mail server that is currently open?
If I uncheck the maintain connection to mail server checkbox... what is the downside on resources? my clients send newsletters and transactional emails all day, maybe about 10k each client.

I don't know what version of ColdFusion you are running but in ColdFusion 9 a new feature was added that allows you to specify the SMTP server settings in your Application.cfc file. Assuming that you have separate Application.cfc files for your 2 sites then perhaps this will work for you.
Here is a reference to the new feature in ColdFusion 9
Here is the text from that referenced page.
Problem
How can I use the different SMTP Server Settings for Applications hosted in ColdFusion server for sending Email.
Solution
By using the new ColdFusion 9 “smtpServersettings" feature in Application.cfc file, we can specify different SMTP server settings for Applications.
Detailed explanation
ColdFusion 9 added a new attribute called "smtpServersettings" to the Application.cfc file. We can specify the SMTP server setting details to "smtpServersettings" attribute of THIS scope in Application.cfc which takes three values and they are server, username and password as a structure.
<cfcomponent displayname="CF9ApplicationVariables" output="false">
<cfset this.name = "CF9ApplicationVariables" />
<cfset this.smtpserversettings = {
server="mailServerAddress",
username="userEamilID",
password="userPassword"
} />
</cfcomponent>
Now the CFMail tag will use the server details for sending mails as mentioned above in "smtpServersetting" in Application.cfc and it won't use the server values specified in the ColdFusion 9 Administrator. If "smtpServersetting" attribute is not used then CFMail will behave as normally.

I ended up modifying the DNS settings in my servers, adding a cname that pointed to the smtp address, smtp.sendgrid.net. I then updated my code to use the new server names, and this seems to be separating the connections.

Related

I've updated CF9 mail server settings but my application is still trying to use the old mail server

We changed our exchange mail server so I've update the mail server in CF9 admin settings. I've verified that it can connect to the new server and it can. But when I test sending an email it keeps failing because it is trying to connect to the old mail server. When I look in the mail.log it clearly lists the old server as the SMTP host it is trying to connect to and it fails.
Where else could CF9 be pulling the old mail server from?
Are there other places where my predecessor could have coded in the old mail server?
I've looked in various .cfm files for any reference to the old exchange server but have found none.
Thanks,
Dan
Ok so what I ended up doing was to actually hard code the new server into the one location we are actually using a cfmail tag. That fixed it. Not much of a chance this app will ever do anything other than this so should be fine.
Dan

Sending Text Messages (SMS) With ColdFusion And CFMail

I'm building a web application that needs to send notifications by SMS. As ColdFusion itself provides an SMS Service, can I use the same for sending SMS without using any 3rd party SMS Gateway Service like Clickatell?
I have found some information at Ben Nadel's website but it is not working,
Sending Text Messages (SMS) With ColdFusion And CFMail
I have tried the following code,
<cfmail to="9567102323#ideacellular.net" from="9567102323" subject="New Message" type="text">
<cfmailpart type="text/plain">Hello huan, this is a test message</cfmailpart>
</cfmail>
As guessed by Miguel in the comments, your code will not give the desired result because the from attribute of your cfmail tag is not a valid email address. Your ColdFusion code will execute without error but the mail will not be sent. The mail file will appear in the Undelivr folder of a path resembling this: yourlocalsystem\JRun4\servers\cfusion\cfusion-ear\cfusion-war\WEB-INF\cfusion\Mail.
For the code in your question, add "#ideacellular.net" to the from attribute of your cfmail tag. From here, I'm a little uncertain. If that mail goes to the Undelivr folder it might have something to do with your mail server only being able to send mail from certain domains. I have vague recollections of stuff like that happening to me.
You can't send SMS direct from ColdFusion, does not have this capability, just like ColdFusion does not have a built-in mail server. cfmail tag makes it easy to communicate with a mail server, but it does not send emails itself.
Regarding SMS, ColdFusion makes it easy to work with SMS gateways, look at CF docs for "SMS Event Gateway" and sendGatewayMessage().

Can I restrict cfmail to only send mail from a given domain using cf admin

We have had issues with our server being used to send spam via cfmail to our remote SMTP server. I cannot see where it is occurring, but the emails are sent from a domain that is not one on our server.
Is there a way using ColdFusion administrator to specify that only emails showing as from someone#mydomain.com are sent to the SMTP host via the spool?
Thanks in advance,
Paul
It sounds to me like the <cfmail> side of things here is a red herring and you have got an open relay on your mail server. You seriously need to disable that immediately! If your SMTP server has to relay email for your CFML app then make sure it's not configured to relay everything, instead just for the IP address of the CF server, or for the credentials the CF server uses to connect to it.
If you don't know how to configure the relaying settings for your SMTP server, raise another question on serverfault.com asking how. Provide the exact details of your SMTP server, as well as the requirement to still allow relaying for the CF server.

Coldfusion 9 cfexchangecalendar exchange server outlook 2007

CF9
Exchange server 2007 (hosted)
I am trying to add a calendar event for a user on our hosted exchange server. I'm getting the error ;
Unable to connect to the Exchange server using HTTP/HTTPS protocol.
HTTP response code : 400
The code is;
<cfexchangeCalendar action="Create"
username="EXCH016\ron_domain"
password="password"
mailboxname="ron"
server="https://owa016.msoutlookonline.net/owa"
Protocol="https"
formbasedauthentication=true
formbasedauthenticationURL="https://owa016.msoutlookonline.net/owa/auth/owaauth.dll"
Event="#sEvent#"
result="theUID">
#theUID#<br>
I know I can contact the server using the following;
<cfhttp URL='https://owa016.msoutlookonline.net/owa' result='res' >
<cfdump var="#res#">
<cfoutput>#res.filecontent#</cfoutput>
I get the form that requests email address and password.
I've been working on this problem for some time now. I can go to the owa page via browser and log in. At this point I'm at a loss on how to debug the problem.
I have had the same type of problem in the past, when one of my customers went from Privately Hosted and Run vs Hosted Solutions.
Although, I never used the formbasedauthentication method when authenticating, maybe this bypasses some of my issues.
The big thing we had issues with is that most Providers don't all WebDav access on their servers.
Since you are getting a 400, bad request, this is what I would look for first.
http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=cfexchange_3.html talks about what CF needs to connect to Exchange, maybe see if the support staff can confirm the setup.
Since you are using HTTPS, have you added the Cert into the JRE cert Store?
Sorry this probably isn't much help, but I hope it helps.

Force cfmail tag to send from a specfic server IP address

Here is my server set up:
Web Server: ColdFusion 10 u10 64-bit, Windows Server 2008 R2, multiple public/private IP addresses.
Mail server: Is a different Windows 2008 R2 server.
Keeping it simple for this question, I have two web sites (this is just theory; using private IPs in example).
Site 1: 10.10.10.1
Site 2: 10.10.10.2
I'm sending mail using the cfmail tag from Site 1 (10.10.10.1), but when I look at the mail headers of the sent emails and the SMTP log on the mail server, it says that the mail was sent from Site 2 (10.10.10.2).
I did some google searches regarding this issue and came up with this bugbase report.
The bug doesn't appear to have been fixed. However, I was wondering if there were any work-arounds. I want the mail that is sent from "Site 1" to have that sites IP address in the email header.
Have you tried specifing the mailserver similar to the below?
<cfmail
to="<<<email>>>"
from="<<<fromEmail>>>"
subject="Some Subject"
type="html"
server="server to send from (ip)"
port="port for mail server">
body=" <<<content here>>>"
By default Coldfusion will use the email server configured in the admin console. By defining mail servers in the cfmail tag this should be overwritten.