PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > php.general > mail function and headers
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
mail function and headers

Réponse
 
LinkBack Outils de la discussion
Vieux 12/03/2008, 15h28   #1
Alain Roger
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut mail function and headers

Hi,

i'm playing a little bit with the mail function from PHP 5.2.4 and email
headers.
here is a snippet of my code:

> $headers = 'From: '.$email."< ".$fromname."
> >\r\n".'Reply-To:'.$email."\r\n".'X-Mailer: PHP/' . phpversion();


if (mail($to, $subject, $body,$headers))

{
>

....
>

}
>


where:
$fromname = $name.",".$firstname;

when i run this code, and click on button "reply-to" it works well... i mean
i reply to end user email address ($email).
but i can see in my "FROM-TO" header space

> From: correct_email_address [mailto:name@strange_email@including_partial_domain _name_of_mywebhosting]
>
>
>

"correct_email_address" is referencing to $email without problem.
but the problem comes from "strange_email@including
_partial_domain_name_of_mywebhosting".
in fact, before @ i get a crazy value and why the rest (after @) i get my
webhosting domain name ?

can i turn this strange email address to the same as $email, in order to
have "From : my_email_address@company.xxx [mailto:
my_email_address@company.xxx]" ?

thanks a lot,

Alain
------------------------------------
Windows XP SP2
PostgreSQL 8.2.4 / MS SQL server 2005
Apache 2.2.4
PHP 5.2.4
C# 2005-2008

  Réponse avec citation
Vieux 12/03/2008, 15h48   #2
Daniel Brown
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [PHP] mail function and headers

On Wed, Mar 12, 2008 at 10:28 AM, Alain Roger <raf.news@gmail.com> wrote:
> Hi,
>
> i'm playing a little bit with the mail function from PHP 5.2.4 and email
> headers.
> here is a snippet of my code:
>
> > $headers = 'From: '.$email."< ".$fromname."
> > >\r\n".'Reply-To:'.$email."\r\n".'X-Mailer: PHP/' . phpversion();


You have the From: header parameters reversed. Try this:

<?
$headers = "From: ".$fromname." <".$email.">\r\n";
$headers .= "Reply-To: ".$email."\r\n";
$headers .= "X-Mailer: PHP/".phpversion()."\r\n";
/*
....
*/
?>

--
</Dan>

Daniel P. Brown
Senior Unix Geek
<? while(1) { $me = $mind--; sleep(86400); } ?>
  Réponse avec citation
Vieux 12/03/2008, 16h11   #3
spacemarc
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [PHP] mail function and headers

2008/3/12, Daniel Brown <parasane@gmail.com>:
> You have the From: header parameters reversed. Try this:
>
> <?
> $headers = "From: ".$fromname." <".$email.">\r\n";
> $headers .= "Reply-To: ".$email."\r\n";
> $headers .= "X-Mailer: PHP/".phpversion()."\r\n";
> /*
> ....
> */
> ?>


you can add these headers:

$header = "From: $fromname<$email>\n";
$header .= "Reply-To: $email\n";
$header .= "Return-Path: <$email>\n";
$header .= "X-Mailer: PHP/" . phpversion() . "\n";
$header .= "MIME-Version: 1.0\n";
$header .= "Content-type: text/plain; charset=iso-8859-1\n";
$header .= "Content-Transfer-encoding: 7bit\n";

Try it.

--
Scripts: http://www.spacemarc.it
  Réponse avec citation
Vieux 12/03/2008, 16h37   #4
Alain Roger
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [PHP] mail function and headers

ok i will try... what about UTF-8 to ensure unicode ?
my website and especially the form which will send this email, will be
filled in by several nationalities... spanish, english, french, slovak,
german,,...
so isn't it easier to set up utf-8 ?

A.

On Wed, Mar 12, 2008 at 4:11 PM, spacemarc <spacemarc@gmail.com> wrote:

> 2008/3/12, Daniel Brown <parasane@gmail.com>:
> > You have the From: header parameters reversed. Try this:
> >
> > <?
> > $headers = "From: ".$fromname." <".$email.">\r\n";
> > $headers .= "Reply-To: ".$email."\r\n";
> > $headers .= "X-Mailer: PHP/".phpversion()."\r\n";
> > /*
> > ....
> > */
> > ?>

>
> you can add these headers:
>
> $header = "From: $fromname<$email>\n";
> $header .= "Reply-To: $email\n";
> $header .= "Return-Path: <$email>\n";
> $header .= "X-Mailer: PHP/" . phpversion() . "\n";
> $header .= "MIME-Version: 1.0\n";
> $header .= "Content-type: text/plain; charset=iso-8859-1\n";
> $header .= "Content-Transfer-encoding: 7bit\n";
>
> Try it.
>
> --
> Scripts: http://www.spacemarc.it
>




--
Alain
------------------------------------
Windows XP SP2
PostgreSQL 8.2.4 / MS SQL server 2005
Apache 2.2.4
PHP 5.2.4
C# 2005-2008

  Réponse avec citation
Vieux 12/03/2008, 16h38   #5
Alain Roger
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Fwd: [PHP] mail function and headers

ok i will try... what about UTF-8 to ensure unicode ?
my website and especially the form which will send this email, will be
filled in by several nationalities... spanish, english, french, slovak,
german,,...
so isn't it easier to set up utf-8 ?

A.


On Wed, Mar 12, 2008 at 4:11 PM, spacemarc <spacemarc@gmail.com> wrote:

> 2008/3/12, Daniel Brown <parasane@gmail.com>:
> > You have the From: header parameters reversed. Try this:
> >
> > <?
> > $headers = "From: ".$fromname." <".$email.">\r\n";
> > $headers .= "Reply-To: ".$email."\r\n";
> > $headers .= "X-Mailer: PHP/".phpversion()."\r\n";
> > /*
> > ....
> > */
> > ?>

>
> you can add these headers:
>
> $header = "From: $fromname<$email>\n";
> $header .= "Reply-To: $email\n";
> $header .= "Return-Path: <$email>\n";
> $header .= "X-Mailer: PHP/" . phpversion() . "\n";
> $header .= "MIME-Version: 1.0\n";
> $header .= "Content-type: text/plain; charset=iso-8859-1\n";
> $header .= "Content-Transfer-encoding: 7bit\n";
>
> Try it.
>
> --
> Scripts: http://www.spacemarc.it
>




--
Alain
------------------------------------
Windows XP SP2
PostgreSQL 8.2.4 / MS SQL server 2005
Apache 2.2.4
PHP 5.2.4
C# 2005-2008



--
Alain
------------------------------------
Windows XP SP2
PostgreSQL 8.2.4 / MS SQL server 2005
Apache 2.2.4
PHP 5.2.4
C# 2005-2008

  Réponse avec citation
Vieux 12/03/2008, 16h45   #6
Alain Roger
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [PHP] mail function and headers

ok, so this is what i got and it is still remaining... :-(

Received: from serdev ([127.0.0.1]) by home.com with MailEnable ESMTP; Wed,
> 12 Mar 2008 16:40:18 +0100
> Date: Wed, 12 Mar 2008 16:40:18 +0100
> Subject: subject 3
> To: mymail@tek.com
> From: raf, news <news.raf@gmail.com>
> Reply-To: news.raf@gmail.com
> Return-Path: <webmaster@localhost_home.com>
> X-Mailer: PHP/5.2.4
> MIME-Version: 1.0
> Content-type: text/plain; charset=iso-8859-1
> Content-Transfer-encoding: 7bit
>


as you can see my Return-Path is still pointing on the wrong direction :-(
any other idea ?

A.

On Wed, Mar 12, 2008 at 4:11 PM, spacemarc <spacemarc@gmail.com> wrote:

> 2008/3/12, Daniel Brown <parasane@gmail.com>:
> > You have the From: header parameters reversed. Try this:
> >
> > <?
> > $headers = "From: ".$fromname." <".$email.">\r\n";
> > $headers .= "Reply-To: ".$email."\r\n";
> > $headers .= "X-Mailer: PHP/".phpversion()."\r\n";
> > /*
> > ....
> > */
> > ?>

>
> you can add these headers:
>
> $header = "From: $fromname<$email>\n";
> $header .= "Reply-To: $email\n";
> $header .= "Return-Path: <$email>\n";
> $header .= "X-Mailer: PHP/" . phpversion() . "\n";
> $header .= "MIME-Version: 1.0\n";
> $header .= "Content-type: text/plain; charset=iso-8859-1\n";
> $header .= "Content-Transfer-encoding: 7bit\n";
>
> Try it.
>
> --
> Scripts: http://www.spacemarc.it
>




--
Alain
------------------------------------
Windows XP SP2
PostgreSQL 8.2.4 / MS SQL server 2005
Apache 2.2.4
PHP 5.2.4
C# 2005-2008

  Réponse avec citation
Vieux 13/03/2008, 00h57   #7
Chris
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [PHP] mail function and headers


> as you can see my Return-Path is still pointing on the wrong direction :-(
> any other idea ?


return-path is set with the 5th mail() param:

mail($to, $subject, $body, $headers, '-freturn_path_email@address.com');


--
Postgresql & php tutorials
http://www.designmagick.com/
  Réponse avec citation
Vieux 13/03/2008, 07h43   #8
Alain Roger
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [PHP] mail function and headers

Hi Chris,

interesting thing, but i get the following error message :
*Warning*: mail()
[function.mail<http://test4.rogtek.com/common/function.mail>]:
SAFE MODE Restriction in effect. The fifth parameter is disabled in SAFE
MODE. in */test4/common/sendmail.php* on line *119*

how can i solve this by only PHP ? i do not have access to web hosting
server or php.ini.
thx,
Alain.


On Thu, Mar 13, 2008 at 12:57 AM, Chris <dmagick@gmail.com> wrote:

>
> > as you can see my Return-Path is still pointing on the wrong direction

> :-(
> > any other idea ?

>
> return-path is set with the 5th mail() param:
>
> mail($to, $subject, $body, $headers, '-freturn_path_email@address.com');
>
>
> --
> Postgresql & php tutorials
> http://www.designmagick.com/
>




--
Alain
------------------------------------
Windows XP SP2
PostgreSQL 8.2.4 / MS SQL server 2005
Apache 2.2.4
PHP 5.2.4
C# 2005-2008

  Réponse avec citation
Vieux 13/03/2008, 08h35   #9
Chris
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [PHP] mail function and headers

Alain Roger wrote:
> Hi Chris,
>
> interesting thing, but i get the following error message :
> *Warning*: mail() [function.mail
> <http://test4.rogtek.com/common/function.mail>]: SAFE MODE Restriction
> in effect. The fifth parameter is disabled in SAFE MODE. in
> */test4/common/sendmail.php* on line *119*
>
> how can i solve this by only PHP ? i do not have access to web hosting
> server or php.ini.


1 of 2 options.

1) Find another host with safe-mode disabled
2) Use something like phpmailer to send your emails through an smtp server

--
Postgresql & php tutorials
http://www.designmagick.com/
  Réponse avec citation
Vieux 13/03/2008, 09h40   #10
Alain Roger
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [PHP] mail function and headers

hiChris,

i've read several forums where this mail() function from PHP initial package
is not so great.
Therefore a lot of people use PHPMailer which is more convenient for that
purpose...especially more flexible.

thanks a lot for your .

Alain

On Thu, Mar 13, 2008 at 8:35 AM, Chris <dmagick@gmail.com> wrote:

> Alain Roger wrote:
> > Hi Chris,
> >
> > interesting thing, but i get the following error message :
> > *Warning*: mail() [function.mail
> > <http://test4.rogtek.com/common/function.mail>]: SAFE MODE Restriction
> > in effect. The fifth parameter is disabled in SAFE MODE. in
> > */test4/common/sendmail.php* on line *119*
> >
> > how can i solve this by only PHP ? i do not have access to web hosting
> > server or php.ini.

>
> 1 of 2 options.
>
> 1) Find another host with safe-mode disabled
> 2) Use something like phpmailer to send your emails through an smtp server
>
> --
> Postgresql & php tutorials
> http://www.designmagick.com/
>




--
Alain
------------------------------------
Windows XP SP2
PostgreSQL 8.2.4 / MS SQL server 2005
Apache 2.2.4
PHP 5.2.4
C# 2005-2008

  Réponse avec citation
Vieux 14/03/2008, 00h55   #11
Chris
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [PHP] mail function and headers

Alain Roger wrote:
> hiChris,
>
> i've read several forums where this mail() function from PHP initial
> package is not so great.


mail() works fine.

phpmailer (and zendmailer, swiftmailer and other such packages) you
with things like:

- sending through an smtp server
- putting a multipart email together
- adding attachments
- embedding images in your email content

and a whole bunch of other stuff so you don't have to write the code to
do all of that.

There's nothing fancy in any of them, and if you don't tell them to send
through an smtp server, they use the normal mail() command (in most
cases I think anyway).

--
Postgresql & php tutorials
http://www.designmagick.com/
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 17h33.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,19529 seconds with 19 queries