#1
  1. Put a potato on it!
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2008
    Location
    Maryland
    Posts
    304
    Rep Power
    971

    Cfmail sending blank emails


    Again, because I'm still learning Coldfusion, I may be missing something but when I use the cfmail tag to send an email and use the cfmailpart tag, the message of the email is blank. The subject, from and to lines are filled in, just not the body.

    Here's the code that I've tried:

    PHP Code:
    <cfmail to="myemail@host.com" from="test@sample.com" subject="TEST - Resetting your password.">
        <
    cfmailpart type="text/html"><cfoutput>test</cfoutput></cfmailpart>
        <
    cfmailpart type="text/plain"><cfoutput>test</cfoutput></cfmailpart>
    </
    cfmail
    and

    PHP Code:
    <cfmail to="myemail@host.com" from="test@sample.com" subject="TEST - Resetting your password.">
    test
        
    <cfmailpart type="text/html"><cfoutput>test</cfoutput></cfmailpart>
    </
    cfmail
    Both of those attempts have blank messages. This sends an email with "test" in the body:

    PHP Code:
    <cfmail to="myemail@host.com" from="test@sample.com" subject="TEST - Resetting your password.">
    test
    </cfmail
    We're using CF9 and I looked at the documentation to make sure that the tags were up to date, as we were on CF 8 until recently. It looks okay to me, but am I missing something that would be causing the blank message?

    Thanks!
    "Those who can make you believe absurdities can make you commit atrocities."
  2. #2
  3. No Profile Picture
    Moderator

    Join Date
    Jun 2002
    Location
    Raleigh, NC
    Posts
    5,264
    Rep Power
    968
    Try something like this:

    Code:
    <cfmail from="yourFrom" to="yourTo" subject="yourSubject">
     <cfmailpart type="plain">
        Plain text
      </cfmailpart>
     <cfmailpart type="html">
        <cfoutput>
          <h1>HTML</h1>
         </cfoutput>
      </cfmailpart>
    </cfmail>
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2008
    Posts
    131
    Rep Power
    7
    Originally Posted by Jyncka
    <cfmailpart type="text/html"><cfoutput>test</cfoutput></cfmailpart>
    Since you mentioned being new to CF, a few tips about <cfoutput>

    1) cfoutput tags are only needed when outputting a CF variable, not plain text.

    2) Even so, they are never needed when the variable is inside a CF tag like cfmailparam, cfquery, etcetera as they are automatically evaluated (see example below)

    So you can safely omit the cfoutput tags from your example.

    Code:
    <!--- notice it works without using cfoutput --->
    <cfset htmlValue = "<h1>Header in HTML</h1>">
    <cfmail to="blah@blah.com" from="blah@blah.com" subject="test">
    	<cfmailpart type="plain">Plain text</cfmailpart>
    	<cfmailpart type="html">#htmlValue#</cfmailpart>
    </cfmail>
  6. #4
  7. Put a potato on it!
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2008
    Location
    Maryland
    Posts
    304
    Rep Power
    971
    That didn't work either, I think it might be the environment we run CF on which is jetty. Jetty is different enough from JRun that maybe it gets to the cfmailpart tag and errors or ignores it...I'm not sure. I'll be looking more into it, once I know more about how CF and it's JVM work together and then read up on Jetty, as that aspect of the language is still an enigma to me.

    Thank you for the suggestion, Kiteless. For the moment I've taken out the cfmailpart tags so that emails can be received.
    "Those who can make you believe absurdities can make you commit atrocities."
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2008
    Posts
    131
    Rep Power
    7
    What CF engine are you using and what do you mean by "did not work", you are still receiving an email with no body?
  10. #6
  11. Put a potato on it!
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2008
    Location
    Maryland
    Posts
    304
    Rep Power
    971
    Yeah, still sending out blank emails when I use the <cfmailpart> tag. We run CF 9 on Jetty and I think that one of those is causing the problem, but this is a lower priority issue so I haven't had time to go and pinpoint it more. It seems more likely that Jetty would be the culprit since I haven't seen a lot of results on Google saying CF 9 has a problem with this particular tag. I know that there's a way to have it output errors, I guess that would be the next logical step.

    Thank you for the advice too, cfSearching. <cfoutput> sometimes confuses me as far as where you need it, but having that straightened out will make my life a little easier.

    Like I said, I have a temporary work around until I can get into it further and see what exactly is breaking, so this thread can be considered solved in the interest of helping other people. If anyone has come across this using the setup we are using, or has any ideas, I'd appreciate hearing them for when I have the time to look.

    Thanks for the help!
    "Those who can make you believe absurdities can make you commit atrocities."

IMN logo majestic logo threadwatch logo seochat tools logo