mail through javascript?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
J_Iceman05
Forum Commoner
Posts: 72
Joined: Wed Aug 03, 2005 10:52 am
Location: Las Vegas, NV

mail through javascript?

Post by J_Iceman05 »

I am using the "phpwebsite" program and i need to do an automatic mail system.

I have tried the php function mail() but for some reason it does not work using this program.
For testing purposes I made a duplicate file containing the mailing section of the code and ran in on our test server, it worked perfectly...
If anyone has an idea as to why this is or how I can get around it I would appreciate your help.

However, becase of this I was thinking that there may be a way to email using javascript that I can just run on the page after thier order, but the only javascript functions I can find open up thier default email program and they would be allowed to edit the information. I need the email to happen without actual knowledge of it from the user.
The order is basically take from the email; so if they edit it, it will mess up the process.
The order can be checked for correctness, but we have to check every email... then things just get really time consuming and complicated.

Here is an example of the php code for reference

Code: Select all

if (mail($address, $subject, $body)) {
  echo 'Your order has been accepted and you will be notified within 2-3 business days.  Thank you for shopping at BD.com';
} else {
  echo 'An unexpected error has occured.  Please try again.';
}
And an example of the javascript code for reference

Code: Select all

address = 'orders@buys.com';
subject ='Orders';
body = "2 boxes of tissue";

window.location = "mailto:"+address+"?subject="+subject+"&body="+body;
Thank you for all of your help.


the phpwebsite program can be found at http://phpwebsite.appstate.edu/
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

no matter what, you will not be allowed to send email through javascript (without some interaction from the user) .. that security-hole in javascript was removed a looooooong time ago.

you'll need to get either mail() working, or use a mailing function/class that does (more often than not) work like phpmailer.
User avatar
J_Iceman05
Forum Commoner
Posts: 72
Joined: Wed Aug 03, 2005 10:52 am
Location: Las Vegas, NV

thnx

Post by J_Iceman05 »

Thank you for your help...
I just wish there was an easier or better way around it... I guess I will just have to bash my head into the wall for a few more hours and try to figure out how to get it working... :cry:
Post Reply