Using <cfmail> with a from attributes that has invalid email account - coldfusion

I want to send an email from error#domain.com to the debugging team debug#domain.com using this simple code
<cfmail to="debug#domain.com" from="error#domain.com"
subject="sending error message plz respond!"
username="sender#domain.com" password="password-correct"
server="mail.domain.com" type="html">
bla bla bla bla blga
</cfmail>
The issue is if the "from" email address is not an existing email account I get a verification error on mail log of ColdFusion although the username is correct. This used to work in cf8, did they now change it?

Has nothing to do with CF and is likely your smtp server. Are you using gmail?

Related

this.smtpServersettings is sending mail to undelivered options instead of gmail

I want to send a email to real gmail ID's to the end users. So I used smtp.gmail.com as mail server with my own email user name & password. But if I use this.smtpServersettings in my application.cfc it's not sending a email. All the mail's are went to undelivered options. My sample code,
App.cfc :
<cfset this.name='mailfn8'>
<cfset this.smtpServersettings={server:"smtp.gmail.com",username:"mygmail#gmail.com",password:"mypassword"}>
My.cfm :
<cfmail from='sender#gmail.com' to='receiver#gmail.com' subject='test' type='html' port="587" usetls="true">
I'm seding a email by using this.smtpServersettings options.
</cfmail>
But the credentials are working great in below scenario,
-- If I set my details in application scope and use that values in cfmail tag
-- Directly set it in coldfusion mail server setting
For example,
App.cfc :
<cfset this.name='mailfn8'>
<cffunction name='onApplicationStart'>
<cfset application.server='smtp.gmail.com'>
<cfset application.username='mygmail#gmail.com'>
<cfset application.password='mypassword'>
</cffunction>
My.cfm :
<cfmail from='sender#gmail.com' to='receiver#gmail.com' server= '#application.server#' username='#application.userName#' password='#application.password#' subject='test' type='html' port="587" usetls="true">
I'm seding a email by using application scope.
</cfmail>
The above working fine. So why this.smtpServersettings is send email to undelivered option instead of gmail. ? .Do I need to enable any other setting if I use this.smtpServerSetting ? Please help me on this. Correct me if I'm understood anything wrong. Thank you !.
The smtpServerSettings struct does not support port and usetls.
https://tracker.adobe.com/#/view/CF-4204467
My suggestion is to create your own struct in application scope then pass to cfmail tag with argumentCollection attribute.

Order of emails is changed when sending multiple emails with CFMail

I have an issue while sending the below two emails through CF 2016. When I run my code I'm receiving the "Password" email first and then the "Username" mail second. The order of sending is getting changed. I need to get "Username" mail first and then "Password" mail. How can I resolve this?
<cfmail to="#toEmail#" from="#fromEmail#" subject="Username" type="html">
Your username is #username#
</cfmail>
<cfmail to="#toEmail#" from="#fromEmail#" subject="Password" type="html">
Your password is #password#
</cfmail>
You can disable mail spooling on a per cfmail basis with spoolEnable. It does slow down the page though. Try it on only the first email. That will send out the first email immediately. Then let the second email get spooled for idle/later delivery.
<cfmail to="#toEmail#" from="#fromEmail#" subject="Username" type="html" spoolEnable="no">
Your username is #username#
</cfmail>
<cfmail to="#toEmail#" from="#fromEmail#" subject="Username" type="html">
Your username is #username#
</cfmail>
You could always to do something like this:
<cfmail to="#toEmail#" from="#fromEmail#" subject="Username" type="html">
Your username is #username#
</cfmail>
<cfthread name="SendPassword" action="run">
<cfscript>
sleep(appropriate number of milliseconds);
</cfscript>
<cfmail to="#toEmail#" from="#fromEmail#" subject="Password" type="html">
Your password is #password#
</cfmail>
</cfthread>
Look at your spool settings to get the appropriate number of milliseconds.

How to stop infinite email response loop coldfusion?

I was testing the cfmail tag within coldfusion and kept refreshing the page and now my email is being spammed consistently with the same code that I wrote in the file. I tried to delete the file but my email keeps getting spammed with the code.
this isnt my real email but this is what I did pretty much. I tried deleting the file to stop the infinite email loop but I keep getting spammed in my email.
<cfmail to="myemail"
from="myemail"
subject="myemail"
type="text">
Dear myemail
We, here at Bedrock, would like to thank you for joining.
Best wishes
Barney
</cfmail>
<cfoutput>
<p>Thank you test for registering.
We have just sent you an email.</p>
</cfoutput>

CFMail sending to first recipient of query result only

When attempting to send an email to multiple recipients using ColdFusion, only the first row is receiving the email and it seems to be hit three times but only sending once. This works but all recipients are visible and the cfoutput is displayed as many times are there are recipients:
<cfmail
to = "#ValueList(getEmail.Schd_Email)#"
from="test#test.edu"
subject="This is a Test"
type="HTML"
query="getEmail"
failto="test#test.com">
The location has been moved to <b><cfoutput>#location#</cfoutput></b><br/>
</cfmail>
This only sends to the first person listed in the query and the cfoutput in the body is still listed as many times as there are recipients.
<cfmail
to = "#Schd_Email#;"
from="test#test.edu"
subject="This is a Test"
type="HTML"
query="getEmail"
failto="test#test.com">
The location has been moved to <b><cfoutput>#location#</cfoutput></b><br/>
</cfmail>
I can output the query to the page and see all emails listed. Not sure why the latter does not work. Any ideas?
I think you should use ';' delimiter in valueList(). the default delimiter for valueList() is ','. If you pass delimiter ';' it might work.
Try this one #ValueList(getEmail.Schd_Email,";")#
Since you are using the query attribute of the cfmail tag you do not need to use the ValueList() function. The query attribute handles that functionality for you. It also negates the need for using a delimeter between each of the "to" addressees. It should work like this assuming you have valid email addresses in your query results.
<cfmail
to="#getEmail.Schd_Email#"
from="test#test.edu"
subject="This is a Test"
type="HTML"
query="getEmail"
failto="test#test.com">
<div>The location has been moved to <b><cfoutput>#location#</cfoutput></b></div>
</cfmail>

CFMail not sending to email address that has a single quote in it

How can I use cfmail to send an email to an address that has a single quote in it? For example:
firstname.o'flanagan#example.com
For some reason I can't get an email sent to that address no matter what I do. Here's the cfmail tag code I'm using. I've tested all the variables and they're all defined:
<cfmail from="#getEmail.from_email#"
to="#email#"
subject="#getEmail.subject#"
type="HTML"
cc="#cc_email#"
bcc="#attributes.bcc_email#"
charset="UTF-8">
Am I missing something? Thanks for the help.
Did you try
<cfmail from="#getEmail.from_email#"
to="#preserveSingleQuotes(email)#"
subject="#getEmail.subject#" type="HTML"
cc="#cc_email#" bcc="#attributes.bcc_email#" charset="UTF-8">
using the PreserveSingleQuotes should allow you to send to that address. Unfortunately using a single quote is valid in an email.