Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using CFMail

Status
Not open for further replies.

rsvirani

Programmer
Aug 22, 2006
5
US
I use cfmail in one of my scripts. However, if there are multiple recipients, and one email address is not valid, the whole email does not get sent. Why is this?
 
for the same reason that outlook won't let you do it, a better question to me is why is that a problem? you should always validate your email addresses before letting cfmail have them. also, i consider it bad practice (don't know if it actually is) to put a bunch of names in any of the to fields of cfmail because of issues such as this - it might be slightly less efficient but a loop over your list of email addresses sending 1 email to each recipient instead of 1 email to ALL recipients would solve this problem (or at least loop over and verify the email addresses before cfmail)

=========================================
Don't sweat the petty things and don't pet the sweaty things.
 
I think looping over the email addresses and sending ONE email per user is a better way. This way everyone does not see everyone else's email.

There are some very good UDF for email validation, I use one currently and its great (let me know if you want that code).

____________________________________
Just Imagine.
 
Thanks guys, yes i would like the UDF email validation code.
 
Yes, i'd back up what these guys have said with regards to looping over the mail tag and sending a mail to each recipient, its a much safer way of doing things, and means you can use personalized content in the mail, such as 'Hello James, Thanks for subscribing...' and so on.

As for validation, check out this CFC, it's written by a guy from another forum but is excelent for validating information of all types.

Infact, all of his CFC's are excelent, but this validation one in particular. If you use it then drop him over a mail, he'll be pleased to know its comming in usefull.


Rob
 
rsvirani, this is the code i've used for email validation.

Code:
<!--- THIS GOES ON THE PAGE THAT PROCESSESS THE FORM --->
<!--- VALIDATES EMAIL ADDRESS TO MAKE SURE ITS SYNTAX IS VALID --->
<cfscript>
	function isEmail(str) {
		return REFindNoCase("^['_a-z0-9-]+(\.['_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*\.(([a-z]{2,3})|(aero|coop|info|museum|name|jobs|travel))$", str) IS 1;
	}
</cfscript>

<cfif #YesNoFormat(isEmail('#FORM.Email#'))# is 0>
	<!--- EMAIL VALIDATE FAILED --->
	<cflocation url="linktopagetoshowerror.cfm?status=1" addtoken="no">
</cfif>


____________________________________
Just Imagine.
 
why not just do this
Code:
<cfinput type="text" name="email" validate="email" required="yes" message="Please enter a valid email address." />[code]
 
daNewfie, that's assuming s/he is using <cfform>.

I have an issue with using <cfform>, in that I don't like using it. <cfform> relies heavily on users having a recent or updated java installed for their browser. I've seen sporadic results where <cfform> validation failes.

____________________________________
Just Imagine.
 
Yeah i'd agree not to bother with cfform, and even if you do, then jump on the validation yourself rather than allowing the form to handle.

I still cant plug that CFC enough, it validates all sorts of form data, and will validate anything you care to pass through it, quickly and effetively.

It's such an easy bolt-on to an application, it makes a usfull tool and is easy to integrate and saves having seperate cfm pages to validate each form, simply have the form submit back to itself, sit the validation script in the header, and if it validates then pass the user to the confirmation page and the data into the entry function for the database.

Rob
 
I just want to make clear about the validation: I need validation that the email is a working email box, not that it is in fact a valid format. For example: if bob@mail.com is a valid format but the email does not actually exist, the whole email with other people in the to parameter does not get sent. The reason it is important that one email be sent is so others in the company can see who else is involved on a certain project.
 
Ah, ok, Well this is a slightly more unusual issue then, i cant see why it would stop email going out if one of the recipients isn't a valid address.

My understanding of how this works, if that CFMAIL will generate a copy of that mail to everyone on the list, if one of those address's isnt working, then it should effect any other mails that have been sent in that 'batch'.

If you need a list of other recipients, you could still use the loop method, and just unclude that list elsewhere in the mail content.

When you say 'does not get sent', what do you mean by this? are you getting an error message, or do the mails just not get recieved?

I really cant see why your getting issues just becuase the mail account is dead on the other end.

Are you sure its not somthing else causing the issue? a dodgy pop server or somthing?

With that in mind, is this an internal server running exchange? or are you posting the mail to several different domains and servers?

Thanks,

Rob

 
rsvirani's issue isn't all that rare, it happens quite often. Case in point, in Hotmail (and even Yahoo Mail) when you add 5 email addresses in the 'TO' field, and one of the email addresses is not real, Hotmail sends an error back stating that one email is not valid and the email has NOT BEEN SENT. Test it out for yourself to see it.

The issue is when you send email to mulitple receipients only ONE email is being sent, and if one of the addresses is faulty then the process stops.

What rsvirani should do since sending mulitple receipients is what s/he wants is check to see if the email is sent (cftry/cfcatch the cfmail tag) and if it fails for whatever reason, in cfcatch redirect the user to an error page notifying them of the issue, and let them retry.

If this is an automated process then in cfcatch send an email to the admin or supervisor of the issue and in that error email list all the addresses that the cfmail attempted to deliver. What I also do is save that info in an error table in the database, this is in case the mail server konked out you have a back up of the error. This also helps in generating a report so higher management can see what emails were sent to who and when.

Know what I mean?

I am off on vacation tomorrow morning til early next week, so if you have a followup question and I don't respond it cause i'm miles away from a PC, :)

____________________________________
Just Imagine.
 
rsvirani, maybe i'm missing something but i've not known any smtp server to act that way. just to make sure i'm not crazy i just composed a mail message to myself and a made up email address of something i know is not a working mail box. i received the message i sent to myself and a mail system error from my mail server for the invalid mailbox, so i don't know what would be denying the other emails for you.

if you want to validate that an email address is a working address then check this out -
=========================================
Don't sweat the petty things and don't pet the sweaty things.
 
Yes, my knowledge of SMTP and Exchange servers would be that you should be getting the results that NorthStarDA is recieving, I can't see why you would have anything else.

I think the hotmail situation is slightly different as I'm pretty sure it only validates hotmail address's, perhaps against a database before it attempts to send.

Or they have thier .net solution tied in closly with an exchange server rather than using the standard SMTP and POP type protocols you would usualy expect to see in this environment.

I'd still be interested to hear what testing you've managed to get done rsvirani and what results you've had come back to you.

Thanks,

Rob
 
The email is being sent to a list of receipients all within the same domain: siemens.com. When I send an email the way NorthStartDA does, I have no issues. I also have a Java application that also sends mail automatically. When this application has a bad recipient, it still gets sent and the from adressee just gets a conventional undeliverable email. This problem is only with the CFmail function. If it helps, we have multiple exchange servers. The Java app and the CF app are running on the same machine and were tested with the same string of emails. Also, if this helps, we are running IIS with Bluedragon to support CFM. ANy advice?
 
rsvirani, did you ever find a solution to this? I am having same issue with cfmail that if one is bad in the list, the email doesn't get sent out. It works ok using my outlook, but not using my relay mail server I am supposed to use when delivering emails through applications... It appears there is a validation for emails from the included link above using webservice="I guess my only issue with that would be that now I'm relying on einsteinware to always be up and validating my email addresses...

Thanks in advance for any assistance on this...
 
Sorry jl8789, I have not found any other solution besides looping over the emails with some web service validator as mentioned above or like your einsteinware find. I can't use these solutions because the server is under heavy security and constant firewall changes so even if I trust a domain today, the admins of the server may untrust it in the future. I may solve the problem with the emails, but I may get more frequent crashes as the server tries to connect to the net and use one of the web services. So, I'm still waiting on a solution/bug fix for cfmail.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top