Jump to content

How to Save sent mail


zed420

Recommended Posts

where the code sends the mail make it save the details to a database or flat file storage system.

 

The database could be set up like:

Database setup

id INT 11 Primary Key auto_increment

sender VARCHAR 20

recipient TEXT

message TEXT

time_sent TIMESTAMP CURRENT TIMESTAMP

sender would not be needed if it is always sent by one person, and recipient can be changed to a number if you have a members table with unique id's.

ya so basically you have your title, body, and who you sent it to

just insert it into a table if the sending is successful

so something like this

 

$mail=mail($recipient, $subject, $mail_body, $header);

if($mail){//mail was sent correctly

$q="INSERT INTO mail ...." etc i think you should know how to insert into a database if not tell me and ill actually type it out

then query $q so ya you should know how to do that too

 

}else{//mail was not sent so i would report this too so you can see when you dont have mail sent succressfully

do something to report mail not setn

 

}

I would say it would be better to save it even if it was unsuccessful, this way you can find out what people have failed to send and if need be recover it.

 

<?php
$mail=mail($recipient, $subject, $mail_body, $header);
if($mail)
{
   $success = 1;//means successful
}
else
{
   $success = 0;//means un-successful
}
mysql_query("INSET INTO table (row,success) VALUES ('value','$success')");
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.