Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

cfmail bcc won't accept variables

New Here ,
Jun 20, 2007 Jun 20, 2007
I am creating an application which will send notifications to users in the system when certain events happen. The cfmail tag that I use sends each message to a generated list of user emails placed in the to attribute. I also want to place a generated list of email into the bcc field for verification of the sent email.

The code that fails is as follows:

<cfmail to="#getUserInfoEmail.email#" bcc="#application.contactEmail#" from="noReply#application.EmailDomain#" subject="Your Username and Password" type="html">
(this code is listed at the end of this post as well)

The #application.contactEmail# variable is set for each instance of my application and used for this purpose in the multiple emails that are generated.

If I change the aforementioned code to have an email directly in the bcc field the cfmail sends successfully.

Notice that in the from field I generate a noreply email based on a different variable. That is accepted and works.

Please advise on anything you may know.
1.5K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Jun 20, 2007 Jun 20, 2007
Have you double checked to make sure your Application.contactEmail variable is defined and set up correctly?
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 20, 2007 Jun 20, 2007
Yes, I've done an output of the variable on the line prior to the cfmail tag and it displays correctly
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jun 20, 2007 Jun 20, 2007
you say that the #application.contactEmail# var is being set correctly. is the email being sent to the TO recipient? have you moved the #application.contactEmail# var to the cc field? try setting the FROM to your email address and see if you get a bounce back from the server. maybe there is whitespace there...
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 21, 2007 Jun 21, 2007
The email is not being sent at all from the original script. I did some debugging and found out that the variable is okay. I removed the bcc and placed that variable as the from email and the message went through as if from the #application.contactEmail# variable. I then tried creating a new variable #myEmail# placing my personal email in the from field and it worked. then I moved it over to the bcc field and again, the email was not sent at all.

After testing all of these I went to a completely different server and tried to replicate the problem. On the other server the email was sent successfully.

I do not have access to the cfadministrator on either of these servers. Does anyone know if there is a setting that could affect this?

I can at least communicate the issue to the server administrator and let him fix it.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Jun 21, 2007 Jun 21, 2007
I went through a similar scenario and it turned out that the mail admin had it set up so that a single email could not be sent to both internal and external recipients at the same time. This might explain why an email with one of your addresses or the other will go through, but the combination will not.

Kind of a longshot, I realize, but worth a look.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jun 21, 2007 Jun 21, 2007
I went through a similar scenario and it turned out that the mail admin had it set up so that a single email could not be sent to both internal and external recipients at the same time.

Yeah, I've seen similar things. The IT boys here are forever fiddling with the mail servers and every few months, it seems, they stumble upon some configuration that throws a wet blanket over at least one of my apps.

NorthernMarks, does the other server (from which the mail was successfully sent) spool off to the same mail server as does the first web server (from which the email failed)? If not, I'd talk to the mail server admin.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 21, 2007 Jun 21, 2007
NorthernMarks,

Is getUserInfoEmail a query? If so, and you wish to send to all addresses in the query, replace getUserInfoEmail.email by valuelist(getUserInfoEmail.email)

<cfset toAddress=getUserInfoEmail.email>
<cfset bccAddress=application.contactEmail>
<cfset fromAddress=noReply & application.EmailDomain >
<cfmail to="#toAddress#" bcc="#bccAddress#" from="#fromAddress#" subject="Your Username and Password" type="html">

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 21, 2007 Jun 21, 2007
in this instance it is not a list. This is sending a user his or her username and password to the application. I'm only using the bcc for testing purposes in this instance.

I have other email notifications where the bcc will be used permanently. I had just used this one as my example here. In the other emails I send I do have lists of emails in the to field and I create that valueList in those cases.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 21, 2007 Jun 21, 2007
Did it make any difference to place application.contactEmail out of the cfmail tag?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 21, 2007 Jun 21, 2007
I don't know exactly what you mean by that. I did test the variable just outside of the cfmail tag in an output tag to test it and it displayed correctly, is that what you were getting at?
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 21, 2007 Jun 21, 2007
I did test the variable just outside of the cfmail tag in an output tag to test it and it displayed correctly, is that what you were getting at?
Not quite. I meant whether you have tested the version I gave.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 21, 2007 Jun 21, 2007
BKBK -
I did try the code you gave and had the same results.

pcbrown -
The two applications are completely separate and do not have the same mail server.

On thought though is that none of the email addresses used are related to the mail server that is related to the hosting server to my app. But on that note, I can get the email to send if I just type in the email addresses, it's when they are passed as a variable that it fails to send. Strange
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 21, 2007 Jun 21, 2007
LATEST
Assign the application variable just before the cfmail tag, just to test. If it works, then the problem is with variable assignment, not with cfmail.

<cfset application.contactEmail="me@mydomain.com">
<cfmail to="#getUserInfoEmail.email#" bcc="#application.contactEmail#" from="noReply#application.EmailDomain#" subject="Your Username and Password" type="html">



Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources