Sending emails in ColdFusion

244 Views Asked by At

I am adding a cfmail tag on one of my websites and the code works fine on my developer server, but when I upload it to the production it doesn't want to work. I have checked the log files, and CF does not show me any errors or undelivered emails. Also I compared my code with other working websites and I did not see any differences that could cause the issue.

Below is my code, please let me know if you see an error, and also have in mind that this code works on development server which has the same configuration with the production server.

<cfif sjResponse['szIsApproved'] eq '1' >

     <cfmail to="#Email#" type="html"

           from="#trim(replace(myStruct.sitename, " ", "", "all"))#"

           subject="Your credit card has been approved for processing">

           <cfmodule template="example.cfm" attributeCollection="#myStruct#">

    </cfmail>

</cfif>  

Thanks for the help

Answer:

from="#trim(replace(myStruct.sitename, " ", "", "all"))#"

That was my mistake. I had the wrong variable in the code. I had to put myStruct.email instead and I just saw it

4

There are 4 best solutions below

0
On BEST ANSWER
from="#trim(replace(myStruct.sitename, " ", "", "all"))#"

That was my mistake. I had the wrong variable in the code. I had to put myStruct.email instead and I just saw it

0
On

Yeah definitely check the mail server settings in CF Administrator. You can also try to bypass those settings by putting the mailer server info right in the cfmail tag. Here is link to the cfdocs for cfmail: http://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WSc3ff6d0ea77859461172e0811cbec22c24-7f8e.html

2
On

Check what your mailserver is in the CF Administrator on your production server. Can the CF server connect to it?

Check your mailserver logs as well.

1
On

As Duncan said, check your mailserver in the CF Administrator on your production server.

Your cfmail tag doesn't specify the "server" parameter, so it will default to whatever is set in the CF Administrator. If this is set in the CF Administrator on your development server but not your production server, that would explain why it works on dev but not prod.