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!

I am using phpmaillist (a mail list

Status
Not open for further replies.

RickBooker

Technical User
Jan 26, 2000
17
0
0
US
I am using phpmaillist (a mail list managment program) When I send mail the headers (From:Subject:etc) show up in the body of the message and nothing shows in my email program(Outlook Express). The From header in the received email shows Apache (my server address) Here is the code in my sendmail.php file. Any point in the right direction would be appreciated greatly.
<html><head><title>Updating file....</title></head><body>
<?
$headers .= &quot;From: Rick <rickbooker@home.com>\n&quot;;
$headers .= &quot;Return-Path: <rickbooker@home.com>\n&quot;;
$addresses = file(&quot;data/$List&quot;);
for ($index=0; $index < count($addresses); $index++)
{
mail(&quot;$addresses[$index]&quot;,$Subject,$Message,$headers);
}
$myfile = fopen(&quot;data/log.txt&quot;,&quot;a&quot;);
fputs($myfile,$Subject.&quot;\t\t&quot;.date(&quot;dS of F Y h:i:s A&quot;).&quot;\t\t&quot;.$List.&quot;\n&quot;);
fclose($myfile);
?>

Mail has been sent to:
<?
echo $List;
?>
<BR>



Home.
</body></html>

 
Hey RickBooker,

Maybe you could try this out.
Code:
for ($index=0; $index < count($addresses); $index++)
{
  ob_start(); // start buffer 
  include(&quot;data/log.txt&quot;); // execute code
  $emailbody = ob_get_contents(); // return executed code 
  ob_end_clean(); // delete the buffer 

mail(&quot;$addresses[$index]&quot;,
      $Subject,
      $emailbody,
      &quot;From: Rick <rickbooker@home.com>\n&quot;
     };
);

Check out some of the output buffering functions.

No spamming now .... :)

-Josh
 
Hey Josh,
Thanks for the reply.

I tried your method but the headers are still showing up in the email body. When I first ran it I got parse errors on the next to the last line of your code. I'm assuming, since I am very new to this, that you accidently reversed the } and the ) Am I correct in this?

Also instead of the actual email body being sent the log.txt file was sent as the body. This is minor and I &quot;think&quot; I can fix that part. Right now I don't care what is sent as long as the headers show up where they belong. LOL

Thanks a ton.
Rick
 
Rick,

Yes you are right. :) The &quot;)&quot; should be &quot;}&quot; at the end of the function.

What do you mean? The log.txt file was sent as the body of the email? Was it placed as an attachment, or did the actual text get put in the email body?

What I usually do is include another php file. So...

include(&quot;templates/email_body.php&quot;); // execute code

This will include everything that is in email_body.php and place it in $emailbody. This way for me works. Example of email_body.php...
Code:
Hello<?print &quot; &quot; . $addresses[$index]?>,

Whatever you want to say.... 

Thank you,
Rick

The good thing about making it a php script is you can change values around. If you know the person's name you can put that in there and make it more personal.

I really don't know why your headers aren't showing up in the right place. I tried it with some of my code and the headers didn't seem to go anywhere.

Check out:

Hope this helps,
-Josh
 
Josh,

The log.txt file is being displayed as the body of the email. I'm assuming this is coming from the &quot;include(&quot;data/log.txt&quot;); &quot; part of your script. The script that I posted first is being called from another .php that has a form on it for entering the actual text of the email with the action of &quot;sendmail.php&quot; (which is the above script)

I placed <? Mail(tofield,subject,body,$headers)\n;?> directly after the mail() section of the above script and it sent two emails to me with the headers displayed correctly for that last mail() but the original one still had the headers displayin in the body.

I can't figure out what is going on here.
Rick
 
Rick,

So your data/log.txt is actually the subject line of your message? If so, then don't do that include(&quot;data/log.txt&quot;) I was assuming that your txt file was the email body. But now I see that you are getting that text from a form.

Here is some code I just wrote..
Code:
<?
// Rick here is the smallest script I could write, doing what you want to do with the headers.

$headers .= &quot;&quot;;
$headers .= &quot;From: Rick <rickbooker@home.com>\n&quot;;
$headers .= &quot;Return-Path: <rickbooker@home.com>\n&quot;; 

  ob_start(); // start buffer 
  include(&quot;tempemail.php&quot;); 
  // tempemail.php is just a copy of this code, you would replace it with your form input.
  $emailbody = ob_get_contents(); // return executed code 
  ob_end_clean(); // delete the buffer 

mail(&quot;rickbooker@home.com&quot;, &quot;Worked for me...&quot;, $emailbody , $headers);
// Really none of the ob stuff is needed, you would just set $emailbody equal to $message in your script.
?>

Maybe it will help you out, I seemed to be able to get the headers to work.

-Josh

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top