How to change Mime-headers

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
dude81
Forum Regular
Posts: 509
Joined: Mon Aug 29, 2005 6:26 am
Location: Pearls City

How to change Mime-headers

Post by dude81 »

Hello,
when I send with the following php code I find
headers as follows. In this I need to change received from apache@localhost. Which php function will help me or else do I need to define it. If so how do I need to define

Code: Select all

X-Gmail-Received: sdfsdf
Delivered-To: myemail@gmail.com
-------------
Received: by 10.38.98.39 with SMTP id v39cs3141rnb;
--------------- 
       Tue, 30 Aug 2005 03:57:54 -0700 (PDT)
Received: by 10.39.3.49 with SMTP id f49mr45592rni;
--------------
        Tue, 30 Aug 2005 03:57:54 -0700 (PDT)
Return-Path: <apache@localhost.localdomain>
-------------
Received: from enb.xyz.com ([47.95.25.53])
------------- 
       by mx.gmail.com with ESMTP id 71si5116017rnb.2005.08.30.03.57.53;
        Tue, 30 Aug 2005 03:57:54 -0700 (PDT)
Received-SPF: neutral (gmail.com: 61.95.205.253 is neither permitted nor denied by domain of apache@localhost.localdomain)
----------------
Received: from localhost.localdomain (abc [192.168.1.52])
-----------------
	by enb.xyz.com (Postfix) with ESMTP id D2AD769142
	for <myemail@gmail.com>; Tue, 30 Aug 2005 16:29:38 +0530 (EST)
Received: from localhost.localdomain (localhost.localdomain [127.0.0.1])
------------	
        by localhost.localdomain (8.13.1/8.13.1) with ESMTP id j86Avon7009050
	for <myemail@gmail.com>; Tue, 6 Sep 2005 16:27:50 +0530
Received: (from apache@localhost)
---------------
	by localhost.localdomain (8.13.1/8.13.1/Submit) id j86AvodI009048;
	Tue, 6 Sep 2005 16:27:50 +0530
Date: Tue, 6 Sep 2005 16:27:50 +0530
----------
Message-Id: <200509061057.j86AvodI009048@localhost.localdomain>
To: myemail@gmail.com
Subject: Test mail from me please ignore
MIME-Version: 1.0
Content-type: text/html; charset=iso-8859-1
From: Some Other <someother@yahoo.com>

Code: Select all

<?
//$to has email adrreses in it
//$subject defined

$headers  = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
 /* additional headers */
$headers .= "From: ".substr($dsa_name,(strpos($dsa_name,'.')+1)) ."<".$email_id.">\r\n";

sendmail($to, $subject, $content, $headers );
?>


feyd | Please use

Code: Select all

and

Code: Select all

tags where approriate when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url]
I'm getting pretty tired of fixing your posts. This is the last one.[/color]
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

you may want to actually send through an SMTP server. phpMailer is often used for such work.
User avatar
dude81
Forum Regular
Posts: 509
Joined: Mon Aug 29, 2005 6:26 am
Location: Pearls City

Post by dude81 »

Hey Feyd,
My problem was the mail is supposed to bounce back to me. that is return path was not set properly. It was going as apache@localhost.
Now I changed the function to as follows
<?php
mail("$to", "$subject", "$content", "$headers", "-f $email_id");

?>
which gets the return path.
-f is the culprit. :P
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

read your private messages, please.
Post Reply