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: blahblah@linhost263.prod.mesa1.secureserver.net"

 

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';
?>

Link to comment
Share on other sites

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>
';
?>

Link to comment
Share on other sites

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";
?>

Link to comment
Share on other sites

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: 

 

Link to comment
Share on other sites

<?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?

Link to comment
Share on other sites

<?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 :(

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.