Jump to content

mail header 'FROM' keeps returning server address not variable


chiefrokka

Recommended Posts

I've been searching for an hour on these forums and trying all sorts of code people have posted for the Mail Headers syntax, but I keep getting the email and it returns the server host for "From: [email protected]"

 

can someone please post code that works with a variable for From:

 

my latest attempt is:

<?php
$to = $Email;
$headers = 'FROM: $Admin_Email';
$headers .= 'Reply-To: $Admin_Email';
$subject = 'work you piece of crap';
$headers  = 'MIME-Version: 1.0' . '\r\n';
$headers .= 'Content-type: text/html; charset=iso-8859-1' . '\r\n';
?>

hmm, still sending the servers address.  I changed code to this.  the message has some html that I took out because I use variables within the tables.

 

<?php
$to = $Email;
$headers = "From: $Admin_Email";
$headers .= "Reply-To: $Admin_Email";
$subject = "Survivor League - $user's Week $Current_Week Pick!";
$headers  = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1" . "\r\n";
$message = '
<html>
<head>
</head>
<body>
</body>
</html>
';
?>

ok I figured it out finally. 

I took out these lines below and it works fine now. 

 

$headers  = "MIME-Version: 1.0" . "\r\n";

$headers .= "Content-type: text/html; charset=iso-8859-1" . "\r\n";

 

so now all I have is:

<?php
$to = $Email;
$headers = "From: $Admin_Email";
$headers .= "Reply-To: $Admin_Email";
?>

ok I just realized that the From: $Admin_Email works but the HTML portion of the email doesn't show up properly without

$headers  = 'MIME-Version: 1.0' . "\r\n";

$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

 

so close but yet so far away.

 

but when I put those 2 in the headers, the email doesn't use the $Admin_Email but sends the servers address.  Is there a way to send HTML as well as using a variable for From: 

 

<?php
$to = $Admin_Email;
$headers = "From: $Admin_Email \r\n";
$headers .= "Reply-To: $Admin_Email \r\n";
// To send HTML mail, the Content-type header must be set
$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
?>

 

the above code didn't work.  I have double quotes for part of the headers with variables then the last 2 are single quotes.  do I have wrong syntax in the first 2 with?

<?php
$to = $Admin_Email;
$headers = "From: $Admin_Email \r\n";
$headers .= "Reply-To: $Admin_Email \r\n";
// To send HTML mail, the Content-type header must be set
$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
?>

 

the above code didn't work.  I have double quotes for part of the headers with variables then the last 2 are single quotes.  do I have wrong syntax in the first 2 with?

 

You are resetting the $headers value before you are not using the .= operator. Using the code below will show all the $header lines.

 

<?php
$to = $Admin_Email;
$headers = "From: $Admin_Email \r\n";
$headers .= "Reply-To: $Admin_Email \r\n";
// To send HTML mail, the Content-type header must be set
$headers .= "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1" . "\r\n";
?>

 

To see what value it is returning, use echo $headers; below all the $headers variables.

 

If this isn't what your asking, look past it, I'm a dumbass at times and don't fully understand your issue :(

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.