Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Email - Change the From

Status
Not open for further replies.

celeron895

Programmer
Jan 29, 2002
81
0
0
US
I am sending an email using the following:
-----------------------------
$headline = $HTTP_POST_VARS['Headline'];
$text = $HTTP_POST_VARS['Text'];

$email_to = "contact@mysite.com";
$email_subject = "Press Release";
$email_message ="The following was submitted as a press release.\n"
."Headline: $headline\n\n"
."Text: $text";

$email_header = "MIME-Version: 1.0\n"
."Content-Type: multipart/mixed;\n"
." boundary=\"{$mime_boundary}\"";

$ok = @mail($email_to, $email_subject, $email_message, $email_header);

header("Location: pressreleasethankyou.shtml");
--------------------------------
How can I change the "from" part of the email? Currently it shows as 'Nobody'.
 
Try this:

=== START CODE EXAMPLE ===
<?php
$headline
= $HTTP_POST_VARS['Headline'];
$text = $HTTP_POST_VARS['Text'];

$email_to = &quot;
Code:
contact@mysite.com
&quot;
;
$email_subject = &quot;Press Release&quot;;
$email_message = &quot;The following was submitted as a press release.\n&quot;
.&quot;Headline: $headline\n\n&quot; .&quot;Text: $text&quot;;

$email_header = &quot;MIME-Version: 1.0\n&quot;
.&quot;Content-Type: multipart/mixed;\n&quot;
.&quot; boundary=\&quot;{$mime_boundary}\&quot;&quot;
.&quot;From: &quot;.$myname.&quot; <&quot;.$myemail.&quot;>\r\n&quot;
.&quot;Reply-To: &quot;.$myname.&quot; <$myreplyemail>\r\n&quot;
;

$ok = @mail($email_to, $email_subject, $email_message, $email_header);

header(&quot;Location: pressreleasethankyou.shtml&quot;);

?>

=== END CODE EXAMPLE === - tleish
 
That may or may not do it.

For example, qmail will override some of the headers with values from environment variables. You may also have to hand sendmail the &quot;-f&quot; parameter (via mail() through the optional &quot;additional parameters&quot; input parameter: Want the best answers? Ask the best questions: TANSTAAFL!
 
Hello

why not just keep it simple;

<?
print &quot;<html><body>&quot;;
$recipient = &quot;<address where you're sending&quot;;
$subject = &quot;Press Release&quot;;
posted at\n$message = &quot;The following was submitted as a press release.

Headline: $headline
Text: $text&quot;;

$extra = &quot;From:<your email address>&quot;;
mail($recipient,$subject,$message,$extra);
print &quot;</body></html>&quot;;
header(&quot;Location: pressreleasethankyou.shtml&quot;);
?>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top