I’m having a bit of an issue with this one.
I can get PHP to send me an email from the “FROM:” I insert without any trouble.
I can get PHP to send me an HTML mail, but it does not show the proper “FROM:” field.
I cannot get it to do both. It will do either/or.
Here is my code:
[SIZE=”5″][FONT=”Arial Black”][COLOR=”Red”]This script sends an email – but not an HTML email.
Form is on Page One:
[code=php]
<body bgcolor=”#000000″>
<p><span class=”style2″><br>
<form method=”post” action=”sendemail2.php”>
<br>
<table width=”435″ border=”0″>
<tr>
<td width=”228″><div align=”right”><span class=”style2″>Email will be sent from: </span></div></td>
<td width=”179″><input name=”email” type=”text”></td>
</tr>
<tr>
<td><div align=”right”><span class=”style2″>Email will be sent to: </span></div></td>
<td><input name=”email2″ type=”text”></td>
</tr>
<tr>
<td><div align=”right”><span class=”style2″>Subject:</span></div></td>
<td><input name=”subject” type=”text”></td>
</tr>
</table>
<br>
<span class=”style2″>Message:</span><br>
<textarea name=”message” rows=”15″ cols=”70″></textarea><br>
<input type=”submit” value=”Send Email”>
</form>
</body>
Here is the PHP page:
[code=php]
<?php
$to = $_REQUEST[’email2′] ;
$subject = $_REQUEST[‘subject’] ;
$email = $_REQUEST[’email’] ;
$message = $_REQUEST[‘message’] ;
$headers = “From: $emailrn” .
“X-Mailer: php”;
$sent = mail($to, $subject, $message, $headers) ;
if($sent)
{print “Your mail was sent successfully”; }
else
{print “We encountered an error sending your mail”; }
?>
[SIZE=”5″][FONT=”Arial Black”][COLOR=”Red”]This script sends an HTML email – but does not display the “From:” address properly.
Form Page:
[code=php]
<form method=”post” action=”sendhtmlmail2.php”>
<br>
<table width=”435″ border=”0″>
<tr>
<td width=”228″><div align=”right”><span class=”style2″>Email will be sent from: </span></div></td>
<td width=”179″><input name=”from” type=”text”></td>
</tr>
<tr>
<td><div align=”right”><span class=”style2″>Email will be sent to: </span></div></td>
<td><input name=”to” type=”text”></td>
</tr>
<tr>
<td><div align=”right”><span class=”style2″>Subject:</span></div></td>
<td><input name=”subject” type=”text”></td>
</tr>
</table>
<br>
<span class=”style2″>Message:</span><br>
<textarea name=”message” rows=”15″ cols=”70″></textarea><br>
<input type=”submit” value=”Send Email”>
</form>
PHP Script page:
[code=php]
<?php
$to = $_REQUEST[‘to’] ;
$subject = $_REQUEST[‘subject’] ;
$from = $_REQUEST[‘from’] ;
$message = “<html><head></head><body bgcolor=”red”><center><font size=”+2″>Test</font><BR><p>Wow, I sent an HTML Mail!</p></body></html>”;
$headers = “Content-type: text/html; charset=iso-8859-1rn”;
$headers .= “From: $fromrn”;
$sent = mail($to, $subject, $message, $headers) ;
if($sent)
{print “Your mail was sent successfully”; }
else
{print “We encountered an error sending your mail”; }
?>
I have not been able to send an HTML mail from the “From:” address I want to use.