Email generation based on table entries...

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
dardsemail
Forum Contributor
Posts: 136
Joined: Thu Jun 03, 2004 9:02 pm

Email generation based on table entries...

Post by dardsemail »

Can anyone point me to some good code on generating an email based on data that has been submitted to a table.

I'm doing a little shopping cart application and would like to email the customer a copy of their order upon successfully placing the order.

Any suggestions of where to look? Also, I know my web hosting provider provides SMTP mail, but is there any specific information I'll need from them in order to complete the script?

Thanks!
User avatar
ol4pr0
Forum Regular
Posts: 926
Joined: Thu Jan 08, 2004 11:22 am
Location: ecuador

Post by ol4pr0 »

Code: Select all

set_time_limit(1200);
	require("Mail.php");
	$headers['From']= "support@{$_SERVER['SERVER_NAME']}";
	$headers['Subject'] ="Registration";
	$to = ($_REQUEST['email']);
	$body  = "Thank you for whatever '".$_POST['formfieldname']."'";
	$body .= '';
	$body .= "This is the time this mail was generated: " . date("F j, Y, g:i a");

	$message=& Mail::Factory('mail');
	$message->send($to,$headers,$body);
dardsemail
Forum Contributor
Posts: 136
Joined: Thu Jun 03, 2004 9:02 pm

Post by dardsemail »

I'd like to try it - can you give me a quick run-down on how it works?

Thanks!
User avatar
ol4pr0
Forum Regular
Posts: 926
Joined: Thu Jan 08, 2004 11:22 am
Location: ecuador

Post by ol4pr0 »

Hm.. Well basicly what you can do with that. ( using PEAR::MIME) in this case.

create a form.
than get all the vars you want from that form or whatever ( or getting them out of a url or database .. )
those vars, put them in the $_REQUEST or $_POST parts.. and thats it.
Post Reply