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.

Link to comment
Share on other sites

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

 

}

Link to comment
Share on other sites

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')");
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.