I have a host company that uses a top level domain and then virtual host (or domains) under that top level domain. I have set up a database floridafamilyorg on florida-family.org. When I use the php mail instruction the email uses the form business-net.com which is my top level domain. When the email is sent, it shows the sender domain part of the email to be my top level domain. Is there a way that the email shows it is from florida-family.org instead. Here is an example. If you go to http://florida-family.org/send_email_5.php and fill out the form, the recipient will get an email from the database email addresses that says they are from firstname.lastname@business-net.com. I would like it to say, firstname.lastname@florida-family.org instead. How can I do that? My Host says this is something you would have to setup within php to set the from address. Below is the script.
<?php
// Turn on magic quotes to prevent SQL injection attacks
if(!get_magic_quotes_gpc())
set_magic_quotes_runtime(1);
// Connect to database
$eg_objConn1 = mysql_connect("localhost", "root", "");
mysql_select_db("floridafamilyorg", $eg_objConn1);
// Get Record Set
$eg_recResult1 = mysql_query("SELECT ffa_content.email_subject, ffa_content.email_content, ffa_content.page_content FROM ffa_content ", $eg_objConn1);
$eg_Result1 = @mysql_fetch_array($eg_recResult1, MYSQL_ASSOC);
// Conditional statement
if(!empty($POST))
{
// Get Record Set
$eg_recResult2 = mysql_query("SELECT send_emails.email_address, send_emails.title, send_emails.name FROM send_emails ", $eg_objConn1);
$eg_Result2 = @mysql_fetch_array($eg_recResult2, MYSQL_ASSOC);
// Check that there are records in the recordset
if(@mysql_num_rows($eg_recResult2) > 0)
{
// Set record set pointer to the start of the record set and begin looping
mysql_data_seek($eg_recResult2, 0);
while($eg_Result2 = mysql_fetch_array($eg_recResult2, MYSQL_ASSOC))
{
$eg_text_1 = "Dear {TITL} {NAM},\n\n{BOD}\n\nSincerely,\n{SENDE}\n{EMAI}\n{ADDRES}\n\n";
$eg_text_1 = str_replace("{TITL}", @$eg_Result2['title'], $eg_text_1);
$eg_text_1 = str_replace("{NAM}", @$eg_Result2['name'], $eg_text_1);
$eg_text_1 = str_replace("{BOD}", @$eg_Result1['email_content'], $eg_text_1);
$eg_text_1 = str_replace("{SENDE}", @$POST['sender_name'], $eg_text_1);
$eg_text_1 = str_replace("{EMAI}", @$POST['senders_email'], $eg_text_1);
$eg_text_1 = str_replace("{ADDRES}", @$POST['senders_address'], $eg_text_1);
}
mysql_data_seek($eg_recResult2, 0);
$eg_Result2 = mysql_fetch_array($eg_recResult2, MYSQL_ASSOC);
}
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<!--
This page has been generated with easyGen. (http://www.easygen.com)
easyGen (c) 2003 - 2007 Symbiant.
-->
<html>
<head>
<title>Untitled</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<table cellspacing="0" cols="1" cellpadding="0" width="100%" border="1">
<tbody>
<tr>
<td>
<p>
<table cellspacing="0" cols="1" cellpadding="0" width="100%" border="1">
<tbody>
<tr>
<td>
</td>
</tr>
<tr>
<td>
<span id="label1"><?php echo @$eg_Result1['page_content'] ?></span>
</td>
</tr>
<tr>
<td>
<form id="Form1" style="WIDTH: 100%" action="<?php echo $SERVER['PHP_SELF'].(@($SERVER['QUERY_STRING'] > ' ') ? '?'.$_SERVER['QUERY_STRING'] : '') ?>" method="post">
<p>
<table cellspacing="0" cols="2" cellpadding="0" width="100%" border="1">
<tbody>
<tr>
<td style="WIDTH: 127px">
Your Full Name</td>
<td style="WIDTH: 862px">
<input id="Text1" style="WIDTH: 858px; HEIGHT: 22px" size="117" name="sender_name"></td>
</tr>
<tr>
<td>
Your Email Address</td>
<td>
<input id="Text2" style="WIDTH: 858px; HEIGHT: 22px" size="117" name="senders_email"></td>
</tr>
<tr>
<td>
Your Address</td>
<td>
<input id="Text3" style="WIDTH: 858px; HEIGHT: 22px" size="117" name="senders_address"></td>
</tr>
<tr>
<td style="HEIGHT: 21px">
Email Subject</td>
<td>
<input id="Text4" style="WIDTH: 858px; HEIGHT: 22px" size="117" value="<?php echo @$eg_Result1['email_subject'] ?>" name="email_subject"></td>
</tr>
<tr>
<td style="HEIGHT: 21px" colspan="2">
<textarea id="TextArea1" style="WIDTH: 989px; HEIGHT: 36px" name="email_content" rows="9" cols="108"><?php echo @$eg_Result1['email_content'] ?></textarea>
</td>
</tr>
<tr>
<td colspan="2">
<input id="Submit1" type="submit" value="Submit Email(s)" name="Submit1"></td>
</tr>
</tbody>
</table>
</p>
<p>
</p>
</form>
</td>
</tr>
</tbody>
</table>
</p>
<p>
</p>
<p>
</p>
<p>
</p>
<p>
</p>
<p>
</p>
<p>
</p>
<p>
</p>
<p>
</p>
</td>
</tr>
</tbody>
</table>
</body>
</html>
<?php
// Tidy up used objects
// Close recordset
if(isset($eg_recResult1)) @mysql_free_result($eg_recResult1);
// Close database connection
if(isset($eg_objConn1)) @mysql_close($eg_objConn1);
// Close recordset
if(isset($eg_recResult2)) @mysql_free_result($eg_recResult2);
?>