Email problem

Set up Lucee Admin to send emails via smtp.gmail.com. When I send a test email, it says it was sent but I can find no further trace of it.

EDIT: I checked the mail log and it says “you have do define the from for the mail” but I can’t see where to do that. Why didn’t the test option tell me that or ask for it?

Anything in remoteclient.log?

OK, typo issue resolved that. I see that Admin uses TLS for the server setting instead of the SSL recommendation of some users. Is that likely to be an issue?

Now getting error message in mail.log saying Username and Password not accepted. Re-entered my credentials several times in case of typo but still the rejections. I logged off and on to Google to confirm I’m using the correct password. Then I noticed that the password in Lucee Admin consists of 1 character (dot) less than I originally entered. My password consists of a mix of characters - are there any characters that it would not accept? Are there any length limitations?

there shouldn’t be? which version of lucee?

if you inspect the password field in dev tools, and then type $0.value is the password correct?

Sorry to be a bit thick but do you mean $0. and then the word ‘value’ or my password?

use $0.value to see what the content of the password form field is

In Dev Tools Console, following the >>, I type $0.value and hit return and it shows “*********”. Is that how?

I’m guessing the number of dots or asterisks is always 9.

Using the same credentials in Coldfusion CF9 sent an email. I’m reluctant to call a Lucee issue but what am I doing wrong.

<!---                       sendSMTPMail                            --->
<!---                                                               --->
<cffunction  name="sendSMTPMail" access="remote" returntype="struct" returnFormat="json">
    <cfargument name="from" type="string" required="yes">
    <cfargument name="subj" type="string" required="yes">
    <cfargument name="toAddr" type="string" required="yes">
    <cfargument name="messageBody" type="string" required="yes">
	<cfset replyStruct = StructNew()>
    <cftry>
		<cfmail subject='#subj#' from='#from#' to='#toAddr#'>
       	'#messageBody#'
        </cfmail> 
        <cfcatch>
        	<cfset replyStruct.status = "CFCATCH-eMail">
            <cfset replyStruct.message = #cfcatch.message#>
            <cfset replyStruct.detail = #cfcatch.detail#>
        	<cfreturn replyStruct>
        </cfcatch>
    </cftry>
    <cfset replyStruct.status = "ALLOK">
     <cfset replyStruct.p2 = '#from#'>
     <cfset replyStruct.p1 = '#subj#'>
    <cfset replyStruct.p3 = '#toAddr#'>
    <cfset replyStruct.p4 = '#messageBody#'>
	<cfreturn replyStruct>
</cffunction>

Perhaps someone will give you the answer you need, but in the meantime, here are a few thoughts of other things you could try, to narrow down where the problem is:

  • when you say (in your first note) that you got confirmation that the mail was sent, what did that come from? Did you mean a test in the Lucee admin? or from your code? from lucee logs?
  • as for it “working” on cf9 and now not Lucee, was the cf9 running on the same box as lucee? If not, there could be an environmental difference such that gmail was ok getting email from the first server and not this one
  • either way, have you considered setting the cfmail to use the server, username, and password attributes, to see if those help? or if they may cause a new error to appear in Lucee? maybe your issue is in a difference in how the lucee admin is configured as compared to the CF9 one. these attributes would override those defaults
  • you may also want to try setting those SAME attributes and values in the a test against CF9, to prove that those DO work there. that could be diagnostically significant, whether they do or do not work (in cf9 or lucee)
  • along the same lines, what about using the usetls and usessl attributes in the lucee version of the code? the defaults in your cf9 admin may be different than those in your lucee admin (again, these attributes would override those defaults). and what if you use those attributes when running against CF9?
  • as a last resort, (assuming the servers are different), you may want to consider setting up lucee on the cf9 server, or vice-versa

Excellent response and thank you Charlie. See my answers below:

  • when you say (in your first note) that you got confirmation that the mail was sent, what did that come from? Did you mean a test in the Lucee admin? or from your code? from lucee logs?

In the Admin area where Mail is set up, there is a “Test”.

  • as for it “working” on cf9 and now not Lucee, was the cf9 running on the same box as lucee? If not, there could be an environmental difference such that gmail was ok getting email from the first server and not this one

Yes, they are on the same box and the objective was to prove that my credentials were ok.

  • either way, have you considered setting the cfmail to use the server, username, and password attributes, to see if those help? or if they may cause a new error to appear in Lucee? maybe your issue is in a difference in how the lucee admin is configured as compared to the CF9 one. these attributes would override those defaults

Not sure how to do that.

  • you may also want to try setting those SAME attributes and values in the a test against CF9, to prove that those DO work there. that could be diagnostically significant, whether they do or do not work (in cf9 or lucee)

see above

  • along the same lines, what about using the usetls and usessl attributes in the lucee version of the code? the defaults in your cf9 admin may be different than those in your lucee admin (again, these attributes would override those defaults). and what if you use those attributes when running against CF9?

How would I do that?

  • as a last resort, (assuming the servers are different), you may want to consider setting up lucee on the cf9 server, or vice-versa

already on the same box.
[/quote]

Used a variation of this and it succeeded!!

<cfmail type="plain"
to="[user@domain.com](mailto:user@domain.com)"
from="Webmaster<[webmaster@domain.org](mailto:webmaster@domain.org)>"
subject="This is a test!"
server="smtp.office365.com" port="587"
username="myusername"
password="mypassword">
Test email on #Dateformat(Now(), 'mm/dd/yyyy')#
</cfmail>

So, as a workaround, bypassing the Mail settings in Lucee allows me to send emails and in that sense, solves my problem.

Good to hear, as a workaround and as a point of diagnosis. Now the question is how that info differs front the lucee admin, which these attributes are overriding. Are you looking at both the web admin and the server admin? They may differ.

Finally, you said in reply to my last note that you wondered how to do what I proposed. I had said, “have you considered setting the cfmail to use the server, username, and password attributes, to see if those help”. Since you say here that you did “a variation of this”, I just wanted to confirm that yes, that is what I meant.

Good point Charlie, I hadn’t looked at web admin so now I’ve set it the same as server admin and when I hit the “send a test message” - it worked! I also need to give you credit for the suggestion about usetls and usessl attributes. I wasn’t aware of them. I guess I still wonder how I would specifically send something via server or web. Why are the two options there?

Glad to hear it helped. As for why the “two options”, I assume you mean the web vs server admin, right? I hoped someone else would have replied by now. I have never fully appreciated the two options. Bottom line, the site one would seem to exist to override the server one.

As for more (why the option exists, how the overrides work, any gotchas to beware), I can say that I also had looked for docs on it and didn’t find any. I hope someone else can help with either such a link, or some more background if any.

1 Like