Skip to main content
Known Participant
October 15, 2008
Question

Why won't this CFMAIL send mail??

  • October 15, 2008
  • 9 replies
  • 1181 views
Hi,

First of all I want to thank those of you that have helped me with a project over the last couple weeks. It's done and working my friends' (and their clients) satisfaction, and I couldn't have gotten there without your help.

I've got one unresolved problem I'm curious about:
On one page, I've got a cfmail that sends emails to candidates using a combination of recordset values and form variables, like so:

<cfoutput query="rs_House_Candidates">
<div>
<cfmail to="#rs_House_Candidates.EMAIL#" replyto="#Form.useremail#" failto="jsuligoy@sbcglobal.net" from="#Form.useremail#" subject="MAINE FAMILIES NEED YOUR HELP" server="relay-hosting.secureserver.net">
Dear #rs_House_Candidates.FIRSTNAME# #rs_House_Candidates.LASTNAME#,

#Form.usermessage#
Sincerely,
#Session.name#
</cfmail>
</div>
</cfoutput>

That works perfectly.

On another page, I'm trying to let a user send a message to friends. The code:

<cfmail to = "#rs_TafTemp.TAF_FRIEND#"
from = "#Session.tafuser#"
subject = "How to Keep Toxic Chemicals Out of Household Products"
server="relay-hosting.secureserver.net">
#rs_TafTemp.TAF_MESSAGE#
</cfmail>

This WON'T work, and I can't figure out why. I know all the variables contain good data because I output them to the page right below where the cfmail runs. They all output fine.

I tried the script with and without the cfoutput wrapping... I didn't think it was necessary since this isn't a repeating region like the first (working) example above, but I tried it with and without. It won't work either way.

HOWEVER, if i replace the "from" address with a static value, it works fine.

Any thoughts? No rush since it's working in a form acceptable to the clients, but it's buggin me.

And thanks again...
Joe
    This topic has been closed for replies.

    9 replies

    Known Participant
    October 23, 2008
    Well, the final answer on this one...

    Michael was kind enough to lend me some server space to try this out on his server. I used EXACT copies of my test pages on the godaddy server, except for altering the mail server setting for his server.

    Worked fine, using form variables for "from" and "to" addresses, on Michael's server. WILL NOT work on godaddy unless I replace one address with a static value.

    So... godaddy-ism. I don't know if it's an intentional cripple or not. But interesting!

    Joe
    Inspiring
    October 16, 2008
    hi Joe -

    send me an email from my site below, i can give you easy ftp to play in
    a sandbox

    Michael Evangelista, Evangelista Design
    Web : www.mredesign.com Blog : www.miuaiga.com
    Developer Newsgroups: news://forums.mredesign.com

    StearmanDriver wrote:
    > Michael,
    >
    > I hate to put you through the trouble, but I'm curious too. If you really
    > don't mind hosting this page for a couple tests, I could email you the page to
    > put up. I'll just change my script again to use form variables, and modify my
    > form page to send the results there. We could see what happens. Let me know
    > if you're interested in that.
    >
    > Azadi,
    >
    > I actually did have that problem at first, since I thought I would need to
    > send from the mail account that came with my hosting. Those accounts only
    > allow 250 relays per day, and they may restrict domains, not sure. When I
    > talked to a godaddy support staffer though, he told me to use that
    > "relay-hosting@secureserver.net" server. He told me it didn't require (or
    > accept) any authentication, and that it had a max limit of 1,000 relays per
    > day. I don't believe it has any domain restrictions, because this script is
    > running (and working) on another page in my site, in the same folder:
    >
    > <cfoutput query="rs_Senate_Candidates">
    > <div>
    > <cfmail to="#rs_Senate_Candidates.EMAIL#" replyto="#Form.useremail#"
    > failto="jsuligo@sbcglobal.net" from="#Form.useremail#" subject="MAINE FAMILIES
    > NEED YOUR HELP" server="relay-hosting.secureserver.net">
    > Dear #rs_Senate_Candidates.FIRSTNAME# #rs_Senate_Candidates.LASTNAME#,
    >
    > #Form.usermessage#
    > Sincerely,
    > #Session.name#
    > </cfmail>
    > </div>
    > </cfoutput>
    >
    > Actually it works twice; there's one for house candidates too. I ran a bunch
    > of mails through these while testing, and I got real lazy about the email
    > addresses I entered. I had changed one district's worth of emails in my
    > candidates database so they all emailed to me. When I ran my tests, I would
    > enter all sorts of stuff for the user's email: "blah@aol.com",
    > "myemail@yahoo.com", "me@gmail.com", even things that identified the test, like
    > "205am@newheader.com". They all sent - every time - to the appropriate
    > candidate's email address. These were all mine, using various domains: aol,
    > sbcglobal, gmail. The only difference between this and my problem script are
    > the use of user-entered variables for both "to" and "from" in the script that
    > doesn't work. Though like I said, I modified it so the "to" value was a
    > recordset variable like the working script... but still no good.
    >
    > Thanks,
    > Joe
    >
    >
    >
    Known Participant
    October 16, 2008
    Michael,

    I hate to put you through the trouble, but I'm curious too. If you really don't mind hosting this page for a couple tests, I could email you the page to put up. I'll just change my script again to use form variables, and modify my form page to send the results there. We could see what happens. Let me know if you're interested in that.

    Azadi,

    I actually did have that problem at first, since I thought I would need to send from the mail account that came with my hosting. Those accounts only allow 250 relays per day, and they may restrict domains, not sure. When I talked to a godaddy support staffer though, he told me to use that "relay-hosting@secureserver.net" server. He told me it didn't require (or accept) any authentication, and that it had a max limit of 1,000 relays per day. I don't believe it has any domain restrictions, because this script is running (and working) on another page in my site, in the same folder:

    <cfoutput query="rs_Senate_Candidates">
    <div>
    <cfmail to="#rs_Senate_Candidates.EMAIL#" replyto="#Form.useremail#" failto="jsuligo@sbcglobal.net" from="#Form.useremail#" subject="MAINE FAMILIES NEED YOUR HELP" server="relay-hosting.secureserver.net">
    Dear #rs_Senate_Candidates.FIRSTNAME# #rs_Senate_Candidates.LASTNAME#,

    #Form.usermessage#
    Sincerely,
    #Session.name#
    </cfmail>
    </div>
    </cfoutput>

    Actually it works twice; there's one for house candidates too. I ran a bunch of mails through these while testing, and I got real lazy about the email addresses I entered. I had changed one district's worth of emails in my candidates database so they all emailed to me. When I ran my tests, I would enter all sorts of stuff for the user's email: "blah@aol.com", "myemail@yahoo.com", "me@gmail.com", even things that identified the test, like "205am@newheader.com". They all sent - every time - to the appropriate candidate's email address. These were all mine, using various domains: aol, sbcglobal, gmail. The only difference between this and my problem script are the use of user-entered variables for both "to" and "from" in the script that doesn't work. Though like I said, I modified it so the "to" value was a recordset variable like the working script... but still no good.

    Thanks,
    Joe

    Inspiring
    October 16, 2008
    it looks like you are using godaddy's mail server to send your emails...
    iirc, godaddy's emails are relayed and you are only allowed X number of
    relays a day (something like 50 i think). so that may be a problem...

    it is also highly likely that they allow sending emails only if FROM
    address is a registered address on godaddy's server, i.e. an email
    address on the domain hosted by godaddy.
    so if you have a mydomain.com hosted with them and you have a
    me@mydomain.com address set up in your account, they will allow emails
    to be sent if you have from="me@mydomain.com". but if you have
    someone@someotherdomain.com in FROM field, they will not allow this
    email to be sent. this is a common practise on shared hosts to prevent
    spamming.

    you may try specifying server (i think you do that already), username
    and password attributes in your cfmail tag, and use an email address
    from your godaddy-hosted domain and its password for the username and
    password attributes.

    hth


    Azadi Saryev
    Sabai-dee.com
    http://www.sabai-dee.com/
    Inspiring
    October 16, 2008
    really strange, Joe.
    I'd be interested to know if your page works as-is on a different server.
    ( can give you temp webspace if you want... just email me...
    very few mail restrictions on my server configuration)

    The variable email address should work fine, I do it all the time.
    really odd.

    Michael Evangelista, Evangelista Design
    Web : www.mredesign.com Blog : www.miuaiga.com
    Developer Newsgroups: news://forums.mredesign.com



    StearmanDriver wrote:
    > Well that would be nice to know... but I've still never found a way to access
    > the error logs on godaddy. I've heard it's not possible. Get what ya pay for
    > ya know...
    >
    > Coldfusion throws no run errors, though. And I don't think it's a server
    > setting problem anyway since those exact server specs work perfectly on two
    > other pages on my site, in the same folder even. That's godaddy's bulk
    > outgoing mail server, and it neither expects nor accepts any authentication.
    >
    > The only factor that seemed to make a difference was the use of a variable vs.
    > a fixed value in the "from" parameter. I never tried it in the "to" parameter.
    > This script - this whole page, actually - is identical to the one that works
    > except for that parameter. When I tried a fixed value and got it working, I
    > left that page alone and made a copy to mess around with, and that's the one
    > I'm still trying the variables on.
    >
    > Originally, I was using form variables for both "to" and "from". Then I tried
    > session variables. Then, I tried writing the "to" value into a database, then
    > <cflocation> to the mailing page, running a query to extract that record, and
    > using the recordset value as the "to" parameter. It still only worked if
    > "from" was a fixed value, not when it was a session variable. And like I said,
    > I outputted all my variables as text on that page, to verify they contained
    > correct data. They all did.
    >
    > I was wondering if this is some kind of security setting on godaddy, that it
    > won't send mail from a user-entered value to a user-entered value. I would
    > have thought the database value would work though, since another script on
    > another page uses a database value. Only difference is, that database
    > information has been there since the beginning, and wasn't just inserted on a
    > previous page. I don't know if a server would be smart enough to figure that
    > out, or if it would care.
    >
    > So I'm stumped. Keep the ideas coming if you have them though!
    > Thanks,
    > Joe
    >
    Known Participant
    October 16, 2008
    Well that would be nice to know... but I've still never found a way to access the error logs on godaddy. I've heard it's not possible. Get what ya pay for ya know...

    Coldfusion throws no run errors, though. And I don't think it's a server setting problem anyway since those exact server specs work perfectly on two other pages on my site, in the same folder even. That's godaddy's bulk outgoing mail server, and it neither expects nor accepts any authentication.

    The only factor that seemed to make a difference was the use of a variable vs. a fixed value in the "from" parameter. I never tried it in the "to" parameter. This script - this whole page, actually - is identical to the one that works except for that parameter. When I tried a fixed value and got it working, I left that page alone and made a copy to mess around with, and that's the one I'm still trying the variables on.

    Originally, I was using form variables for both "to" and "from". Then I tried session variables. Then, I tried writing the "to" value into a database, then <cflocation> to the mailing page, running a query to extract that record, and using the recordset value as the "to" parameter. It still only worked if "from" was a fixed value, not when it was a session variable. And like I said, I outputted all my variables as text on that page, to verify they contained correct data. They all did.

    I was wondering if this is some kind of security setting on godaddy, that it won't send mail from a user-entered value to a user-entered value. I would have thought the database value would work though, since another script on another page uses a database value. Only difference is, that database information has been there since the beginning, and wasn't just inserted on a previous page. I don't know if a server would be smart enough to figure that out, or if it would care.

    So I'm stumped. Keep the ideas coming if you have them though!
    Thanks,
    Joe
    Inspiring
    October 16, 2008
    ooh... good point.
    I see the OP is using the server attribute but no user name / pw.

    Without more info about the exact problem, this is one of those 'i'd
    have to see it and test it to know' situations.


    Michael Evangelista, Evangelista Design
    Web : www.mredesign.com Blog : www.miuaiga.com
    Developer Newsgroups: news://forums.mredesign.com

    fober1 wrote:
    > What error do you receive?
    > Do the email files in the folder "C:\CFusionMX7\Mail\Spool" get created?
    > If yes then it is a problem with CF <=> Email server.
    > If not then the attributes you are using for the tag problem are incorrect.
    >
    > Many email servers are setup so they only allow to send email for
    > authenticated users, so your CF script may have to first login to the email
    > server to "retrieve email", before being able to send.
    >
    > This could explain the "some times it works/ sometimes it don't". Have a look
    > how to login to an email server with CF.
    >
    > cheers,
    > fober
    >
    Inspiring
    October 15, 2008
    What error do you receive?
    Do the email files in the folder "C:\CFusionMX7\Mail\Spool" get created?
    If yes then it is a problem with CF <=> Email server.
    If not then the attributes you are using for the tag problem are incorrect.

    Many email servers are setup so they only allow to send email for authenticated users, so your CF script may have to first login to the email server to "retrieve email", before being able to send.

    This could explain the "some times it works/ sometimes it don't". Have a look how to login to an email server with CF.

    p.s. some email servers only allow to relay email for "known users", means for email addresses with the right domain name.

    cheers,
    fober
    Inspiring
    October 15, 2008
    > HOWEVER, if i replace the "from" address with a static value, it
    works fine.


    are you sure the dynamic address is ok?

    i.e.
    <cfoutput>#Session.tafuser#</cfoutput>

    What does that give you?

    If that looks like a valid email address, could it be a whitespace problem?

    Try
    from = "#trim(Session.tafuser)#"

    Any difference ??


    --
    Michael Evangelista, Evangelista Design
    Web : www.mredesign.com
    Forums: news://forums.mredesign.com
    Blog : www.miuaiga.com



    StearmanDriver wrote:
    > Hi,
    >
    > First of all I want to thank those of you that have helped me with a project
    > over the last couple weeks. It's done and working my friends' (and their
    > clients) satisfaction, and I couldn't have gotten there without your help.
    >
    > I've got one unresolved problem I'm curious about:
    > On one page, I've got a cfmail that sends emails to candidates using a
    > combination of recordset values and form variables, like so:
    >
    > <cfoutput query="rs_House_Candidates">
    > <div>
    > <cfmail to="#rs_House_Candidates.EMAIL#" replyto="#Form.useremail#"
    > failto="jsuligoy@sbcglobal.net" from="#Form.useremail#" subject="MAINE FAMILIES
    > NEED YOUR HELP" server="relay-hosting.secureserver.net">
    > Dear #rs_House_Candidates.FIRSTNAME# #rs_House_Candidates.LASTNAME#,
    >
    > #Form.usermessage#
    > Sincerely,
    > #Session.name#
    > </cfmail>
    > </div>
    > </cfoutput>
    >
    > That works perfectly.
    >
    > On another page, I'm trying to let a user send a message to friends. The code:
    >
    > <cfmail to = "#rs_TafTemp.TAF_FRIEND#"
    > from = "#Session.tafuser#"
    > subject = "How to Keep Toxic Chemicals Out of Household Products"
    > server="relay-hosting.secureserver.net">
    > #rs_TafTemp.TAF_MESSAGE#
    > </cfmail>
    >
    > This WON'T work, and I can't figure out why. I know all the variables contain
    > good data because I output them to the page right below where the cfmail runs.
    > They all output fine.
    >
    > I tried the script with and without the cfoutput wrapping... I didn't think it
    > was necessary since this isn't a repeating region like the first (working)
    > example above, but I tried it with and without. It won't work either way.
    >
    > HOWEVER, if i replace the "from" address with a static value, it works fine.
    >
    > Any thoughts? No rush since it's working in a form acceptable to the clients,
    > but it's buggin me.
    >
    > And thanks again...
    > Joe
    >

    --

    --
    Michael Evangelista, Evangelista Design
    Web : www.mredesign.com
    Forums: news://forums.mredesign.com
    Blog : www.miuaiga.com
    Known Participant
    October 15, 2008
    > HOWEVER, if i replace the "from" address with a static value, it
    works fine.
    are you sure the dynamic address is ok?
    i.e.
    <cfoutput>#Session.tafuser#</cfoutput>

    >What does that give you?

    They output fine, like so:

    From= "fromme@aol.com"
    To = "tome@aol.com"

    The quotes are mine, with the <cfoutput> tags inside them, to make sure there was not whitespace. I tried the trim statement as well, with the same result. Weird thing is, now it won't send emails with static values either, which it was doing last night. Yet, the other page with cfmail on it, in the same folder on the same domain, sending to the same server, is working fine.

    So maybe it's a godaddy-ism. I've seen enough of those on this project. It's not important to the project, I just want to make sure I'm using this correctly. Thanks for looking, and if you have any other suggestions I'd love to hear them.

    Joe