to send e-mail on click

I have a page in my application, when the user press 'pay' they ge sent to the online credit card processor.
I also wish to make an automatic e-mail be sent to them when they press pay.
the way I have it setup right now is using cfinclude, but that means that the moment they reach this page
they automatically get the e-mail although they might decied to go back and change something
how can I set this up
I imagine it would be though JS!but I don't know
thanks for the help
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

so if pay is a link  ...  <A HREF="somepage.cfm?email=yes">pay</A>

you should notice how the query string contains the email = yes

now in your page... you use the following code

<CFIF IsDefined("") AND EQ "yes">

 SUBJECT="subject title ">



How about don't send the email until they reach the confirmation page.
MMsabryAuthor Commented:
you see the page they go to after they press "pay" (which is a button) is not on my server, it is on the cc processor server.
The reason for sending this e-mail now (which I did not do before) is that orginally the system was designed to send the e-mail after they go to the processor and come back to my site, then I show the confirmation page with the payment status. But that for some reason did not work always, as I have noticed some users did not get redirected back to my page, although the information is already in the db, I did not get any notices that there have been some activity on my site. Thus I switched to this one, where they get one before they leave my site and one after
Well javascript cannot send the email message.

So how about this

Have the page submit to another one of your pages when they hit pay.  You send the email and then redirect /resubmit to where they are going to pay.  You can have the email say something like : THis is a preliminary confirmation.

Or will the CC server send them back to your site when paying is done? It sounds like it.   If so then send the email at that point with the confirmation page.

Or have a trigger/task (depending on database) that checks for new orders and sends you a message or them a message at the correct time.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Servers

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.