Jump to content

Sending an email


taz321

Recommended Posts

Hi

 

Iv developed a help desk system and want an section in the system where a user would inform a client of the progress of their query by emailing them.

 

I believe Dreamweaver (which i am using to design my system) has this as a feature but not the way i would like it.

Within my system is stored (Client table) the clients contact details such as email address.

 

I would like to email that particular client with their email address from the database pre-filled in when i click on the email button with details of the query filled in as well (all read from the database)

 

I hope thats clear.

 

Any help would be appreciated.

 

Thanks

 

 

 

 

 

 

 

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/96330-sending-an-email/
Share on other sites

Sorry may have worded it badly.

 

Didnt mean to sound like i wanted it done for me, im just at a lost with this and just wanted some advice on how to go about doing it.

 

This is the code i have already -

 

<a href="mailto:??"> but not sure how i would express the code here to read from the database.

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/96330-sending-an-email/#findComment-493091
Share on other sites


mysql_connect('localhost', 'root', 'password') or die('Failed');
mysql_select_db('database') or die('Failed');

$q = 'SELECT `name`, `email` FROM `client_table`' . ( is_numeric($id) ? ' WHERE `id`=' . $id : '');

if (!$r = mysql_query($q) )
   echo 'Query error:<br>' . mysql_error();
else {
   if (mysql_num_rows($r) < 1)
      echo 'No rows found';
   else
      while ($data = mysql_fetch_assoc($r) )
         echo '<a href="mailto:' . $data['email'] . '">' . $data['name'] . '</a>';

}

Link to comment
https://forums.phpfreaks.com/topic/96330-sending-an-email/#findComment-493103
Share on other sites

Hi

 

Im not quite understanding the code given above.

 

I have looked at a few different sites and have seen this code come up a few times

 

<?php
$to = "[email protected]";
$subject = "Test mail";
$message = "Hello! This is a simple email message.";
$from = "[email protected]";
$headers = "From: $from";
mail($to,$subject,$message,$headers);
echo "Mail Sent.";
?>

 

But i want the $to, $subject and $message to read from the database instead of me hardcoding it (like above).

 

Any ideas how i could do this.

 

Thanks in advance.

Link to comment
https://forums.phpfreaks.com/topic/96330-sending-an-email/#findComment-493369
Share on other sites

how is the database set up??

 

run a query to get the data from the database and then assign the data dynamically

$query = "SELECT * FROM table";
$result = mysql_query($query) or die ("Error in query" . mysql_error());
while ($row = mysql_fetch_assoc($result)
{
$to = $row['to'];
$subject = $row['subject'];
$message = $row['message'];
$from = $row['frommail'];
$headers = "From: $from";
mail($to,$subject,$message,$headers);
echo "Mail Sent to $to <BR>";
}

Link to comment
https://forums.phpfreaks.com/topic/96330-sending-an-email/#findComment-493374
Share on other sites

Just a quick question.

 

I need the email to read from 2 tables, which are: -

 

Client

Form

 

From client i would need  - email

From Form i would need - issuetitle, systemaffected, issuedetails & supportcomments.

 

Would i need to join the two tables together in the SQL statement and create another table in my database to show this?

 

Any suggestions how i could do this ?

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/96330-sending-an-email/#findComment-493400
Share on other sites

is it a join you want but we dont no the id name try this

change the id name.........

 

<?php
$sql="SELECT 
client.email,
form.issuetitle,
form.systemaffected,
form.issuedetails,
form.supportcomments
FROM  client,form WHERE client.id=form.id";
$sql_result=mysql_query($sql)or die(mysql_error());
while ($row = mysql_fetch_assoc($sql)
{
$x="system affected: ".$row['systemaffected']." <br><br> Issue:".$row['issuedetails']." <br><br>  comments: ".$row['supportcomments']." ";

$to = $row['email'];
$subject = $row['issuetitle'];
$message = $x;
$from = $row['frommail'];
$headers = "From: $from";
mail($to,$subject,$message,$headers);
echo "Mail Sent to $to <BR>";
}
?>

                         

 

Link to comment
https://forums.phpfreaks.com/topic/96330-sending-an-email/#findComment-493430
Share on other sites

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.