Newbie needs help with mail function

Hi,

I've got so far with the mail() function but it won't work. Please help.
WHere am I going wrong?

Kind regards,

Raj (Newbie)


$to="def [at] ghi.com";
$email_system="abc [at] def.com";
$message="Hi";
$headers = "From: ".$email_system."\n";
$headers .= "Reply-To: <".$email_system.">\n";
$headers .= "X-Sender: <".$email_system.">\n";
$headers .= "X-Mailer: PHP4\n"; //mailer
$headers .= "X-Priority: 3\n"; //1 UrgentMessage, 3 Normal
$headers .= "Return-Path: <".$email_system.">\n";
mail($to,"Verify Email Address for Hi", $message, $headers);
raj [ So, 18 Februar 2007 20:34 ] [ ID #1632946 ]

Re: Newbie needs help with mail function

Op Sun, 18 Feb 2007 19:34:57 +0000, schreef raj:

> I've got so far with the mail() function but it won't work. Please help.
> WHere am I going wrong?
snip
> mail($to,"Verify Email Address for Hi", $message, $headers);

i am a newbie too, but the second entry i don't understand. Should be st
like $subject

--
groet,
Henk Koster jr.
http://www.interinfra.nl/opensource.htm
http://www.xs4all.nl/~qqoopp/kennemlinks.htm
interinfra.haalweg [ So, 18 Februar 2007 21:27 ] [ ID #1632950 ]

Re: Newbie needs help with mail function

On Feb 18, 2:34 pm, raj <r... [at] nospam.com> wrote:
> Hi,
>
> I've got so far with the mail() function but it won't work. Please help.
> WHere am I going wrong?
>
> Kind regards,
>
> Raj (Newbie)
>
> $to="d... [at] ghi.com";
> $email_system="a... [at] def.com";
> $message="Hi";
> $headers = "From: ".$email_system."\n";
> $headers .= "Reply-To: <".$email_system.">\n";
> $headers .= "X-Sender: <".$email_system.">\n";
> $headers .= "X-Mailer: PHP4\n"; //mailer
> $headers .= "X-Priority: 3\n"; //1 UrgentMessage, 3 Normal
> $headers .= "Return-Path: <".$email_system.">\n";
> mail($to,"Verify Email Address for Hi", $message, $headers);

What do you mean by "it won't work?" As in PHP gives you an error?
As in the email never gets there? You need to be more specific.

In any case, your various headers need to be seperated by \r\n not
just \n. And don't include the Reply-To, X-Sender, X-Mailer, X-
Priority, or Return-Path headers -- you don't really need them in your
case.
zeldorblat [ So, 18 Februar 2007 22:40 ] [ ID #1632952 ]

Re: Newbie needs help with mail function

Op Sun, 18 Feb 2007 19:34:57 +0000, schreef raj:

> I've got so far with the mail() function but it won't work. Please help.
> WHere am I going wrong?
snip
> mail($to,"Verify Email Address for Hi", $message, $headers);

i am a newbie too, but the second entry i don't understand. Should be st
like $subject

--
groet,
Henk Koster jr.
http://www.interinfra.nl/opensource.htm
http://www.xs4all.nl/~qqoopp/kennemlinks.htm
interinfra.haalweg [ So, 18 Februar 2007 21:27 ] [ ID #1632959 ]

Re: Newbie needs help with mail function

On Feb 18, 2:34 pm, raj <r... [at] nospam.com> wrote:
> Hi,
>
> I've got so far with the mail() function but it won't work. Please help.
> WHere am I going wrong?
>
> Kind regards,
>
> Raj (Newbie)
>
> $to="d... [at] ghi.com";
> $email_system="a... [at] def.com";
> $message="Hi";
> $headers = "From: ".$email_system."\n";
> $headers .= "Reply-To: <".$email_system.">\n";
> $headers .= "X-Sender: <".$email_system.">\n";
> $headers .= "X-Mailer: PHP4\n"; //mailer
> $headers .= "X-Priority: 3\n"; //1 UrgentMessage, 3 Normal
> $headers .= "Return-Path: <".$email_system.">\n";
> mail($to,"Verify Email Address for Hi", $message, $headers);

What do you mean by "it won't work?" As in PHP gives you an error?
As in the email never gets there? You need to be more specific.

In any case, your various headers need to be seperated by \r\n not
just \n. And don't include the Reply-To, X-Sender, X-Mailer, X-
Priority, or Return-Path headers -- you don't really need them in your
case.
zeldorblat [ So, 18 Februar 2007 22:40 ] [ ID #1632960 ]

Re: Newbie needs help with mail function

Op Sun, 18 Feb 2007 19:34:57 +0000, schreef raj:

> I've got so far with the mail() function but it won't work. Please help.
> WHere am I going wrong?
snip
> mail($to,"Verify Email Address for Hi", $message, $headers);

i am a newbie too, but the second entry i don't understand. Should be st
like $subject

--
groet,
Henk Koster jr.
http://www.interinfra.nl/opensource.htm
http://www.xs4all.nl/~qqoopp/kennemlinks.htm
interinfra.haalweg [ So, 18 Februar 2007 21:27 ] [ ID #1633018 ]

Re: Newbie needs help with mail function

On Feb 18, 2:34 pm, raj <r... [at] nospam.com> wrote:
> Hi,
>
> I've got so far with the mail() function but it won't work. Please help.
> WHere am I going wrong?
>
> Kind regards,
>
> Raj (Newbie)
>
> $to="d... [at] ghi.com";
> $email_system="a... [at] def.com";
> $message="Hi";
> $headers = "From: ".$email_system."\n";
> $headers .= "Reply-To: <".$email_system.">\n";
> $headers .= "X-Sender: <".$email_system.">\n";
> $headers .= "X-Mailer: PHP4\n"; //mailer
> $headers .= "X-Priority: 3\n"; //1 UrgentMessage, 3 Normal
> $headers .= "Return-Path: <".$email_system.">\n";
> mail($to,"Verify Email Address for Hi", $message, $headers);

What do you mean by "it won't work?" As in PHP gives you an error?
As in the email never gets there? You need to be more specific.

In any case, your various headers need to be seperated by \r\n not
just \n. And don't include the Reply-To, X-Sender, X-Mailer, X-
Priority, or Return-Path headers -- you don't really need them in your
case.
zeldorblat [ So, 18 Februar 2007 22:40 ] [ ID #1633022 ]

Re: Newbie needs help with mail function

Op Sun, 18 Feb 2007 13:40:36 -0800, schreef ZeldorBlat:

> In any case, your various headers need to be seperated by \r\n not
> just \n.

another question from me now, it was hard to find a thorough explanation
of the exact meaning of \n and \r, what do they do exactly?

--
groet,
Henk Koster jr.
http://www.xs4all.nl/~qqoopp/anako.htm
interinfra.haalweg [ Mo, 19 Februar 2007 07:37 ] [ ID #1633857 ]

Re: Newbie needs help with mail function

"Koster, H" <interinfra.haalweg [at] localhost.localdomain> wrote in message
news:45d945bc$0$336$e4fe514c [at] news.xs4all.nl...
> Op Sun, 18 Feb 2007 13:40:36 -0800, schreef ZeldorBlat:
>
>> In any case, your various headers need to be seperated by \r\n not
>> just \n.
>
> another question from me now, it was hard to find a thorough explanation
> of the exact meaning of \n and \r, what do they do exactly?


Fun with ASCII, part 0x65

\r = carriage return = sets the cursor at the beginning of the row
\n = line feed = begins a new line

(By your powers combined, I am Captain Carriage Return And New Line!)

\r\n in a windows system is the character combination that gives you a new
line to write to. This is different in *nix based system, where only \n is
needed, the \r is implied. And just to make it fun, this is also different
in a Mac system, where only \r is needed and \n is implied.

So in total we have three different and fun ways for presenting a new line:
\r\n in Windows
\n in *nix
\r in Mac

This of course is a great way to create confusion and anger.

--
"Ohjelmoija on organismi joka muuttaa kofeiinia koodiksi" - lpk
http://outolempi.net/ahdistus/ - Satunnaisesti päivittyvä nettisarjis
spam [at] outolempi.net | rot13(xvzzb [at] bhgbyrzcv.arg)
Kimmo Laine [ Mo, 19 Februar 2007 09:21 ] [ ID #1633860 ]

Re: Newbie needs help with mail function

Koster, H wrote:
> Op Sun, 18 Feb 2007 19:34:57 +0000, schreef raj:
>
>> I've got so far with the mail() function but it won't work. Please help.
>> WHere am I going wrong?
> snip
>> mail($to,"Verify Email Address for Hi", $message, $headers);
>
> i am a newbie too, but the second entry i don't understand. Should be st
> like $subject
>

Yes, thats the subject.

You can read more about it at http://www.php.net/manual/en/function.mail.php
in case you haven't already done that.

--

//Aho
Shion [ Mo, 19 Februar 2007 09:53 ] [ ID #1633863 ]

Re: Newbie needs help with mail function

Op Sun, 18 Feb 2007 13:40:36 -0800, schreef ZeldorBlat:

> In any case, your various headers need to be seperated by \r\n not
> just \n.

another question from me now, it was hard to find a thorough explanation
of the exact meaning of \n and \r, what do they do exactly?

--
groet,
Henk Koster jr.
http://www.xs4all.nl/~qqoopp/anako.htm
interinfra.haalweg [ Mo, 19 Februar 2007 07:37 ] [ ID #1633879 ]

Re: Newbie needs help with mail function

"Koster, H" <interinfra.haalweg [at] localhost.localdomain> wrote in message
news:45d945bc$0$336$e4fe514c [at] news.xs4all.nl...
> Op Sun, 18 Feb 2007 13:40:36 -0800, schreef ZeldorBlat:
>
>> In any case, your various headers need to be seperated by \r\n not
>> just \n.
>
> another question from me now, it was hard to find a thorough explanation
> of the exact meaning of \n and \r, what do they do exactly?


Fun with ASCII, part 0x65

\r = carriage return = sets the cursor at the beginning of the row
\n = line feed = begins a new line

(By your powers combined, I am Captain Carriage Return And New Line!)

\r\n in a windows system is the character combination that gives you a new
line to write to. This is different in *nix based system, where only \n is
needed, the \r is implied. And just to make it fun, this is also different
in a Mac system, where only \r is needed and \n is implied.

So in total we have three different and fun ways for presenting a new line:
\r\n in Windows
\n in *nix
\r in Mac

This of course is a great way to create confusion and anger.

--
"Ohjelmoija on organismi joka muuttaa kofeiinia koodiksi" - lpk
http://outolempi.net/ahdistus/ - Satunnaisesti päivittyvä nettisarjis
spam [at] outolempi.net | rot13(xvzzb [at] bhgbyrzcv.arg)
Kimmo Laine [ Mo, 19 Februar 2007 09:21 ] [ ID #1633882 ]

Re: Newbie needs help with mail function

Koster, H wrote:
> Op Sun, 18 Feb 2007 19:34:57 +0000, schreef raj:
>
>> I've got so far with the mail() function but it won't work. Please help.
>> WHere am I going wrong?
> snip
>> mail($to,"Verify Email Address for Hi", $message, $headers);
>
> i am a newbie too, but the second entry i don't understand. Should be st
> like $subject
>

Yes, thats the subject.

You can read more about it at http://www.php.net/manual/en/function.mail.php
in case you haven't already done that.

--

//Aho
Shion [ Mo, 19 Februar 2007 09:53 ] [ ID #1633884 ]

Re: Newbie needs help with mail function

Op Sun, 18 Feb 2007 13:40:36 -0800, schreef ZeldorBlat:

> In any case, your various headers need to be seperated by \r\n not
> just \n.

another question from me now, it was hard to find a thorough explanation
of the exact meaning of \n and \r, what do they do exactly?

--
groet,
Henk Koster jr.
http://www.xs4all.nl/~qqoopp/anako.htm
interinfra.haalweg [ Mo, 19 Februar 2007 07:37 ] [ ID #1633900 ]

Re: Newbie needs help with mail function

"Koster, H" <interinfra.haalweg [at] localhost.localdomain> wrote in message
news:45d945bc$0$336$e4fe514c [at] news.xs4all.nl...
> Op Sun, 18 Feb 2007 13:40:36 -0800, schreef ZeldorBlat:
>
>> In any case, your various headers need to be seperated by \r\n not
>> just \n.
>
> another question from me now, it was hard to find a thorough explanation
> of the exact meaning of \n and \r, what do they do exactly?


Fun with ASCII, part 0x65

\r = carriage return = sets the cursor at the beginning of the row
\n = line feed = begins a new line

(By your powers combined, I am Captain Carriage Return And New Line!)

\r\n in a windows system is the character combination that gives you a new
line to write to. This is different in *nix based system, where only \n is
needed, the \r is implied. And just to make it fun, this is also different
in a Mac system, where only \r is needed and \n is implied.

So in total we have three different and fun ways for presenting a new line:
\r\n in Windows
\n in *nix
\r in Mac

This of course is a great way to create confusion and anger.

--
"Ohjelmoija on organismi joka muuttaa kofeiinia koodiksi" - lpk
http://outolempi.net/ahdistus/ - Satunnaisesti päivittyvä nettisarjis
spam [at] outolempi.net | rot13(xvzzb [at] bhgbyrzcv.arg)
Kimmo Laine [ Mo, 19 Februar 2007 09:21 ] [ ID #1633902 ]

Re: Newbie needs help with mail function

Koster, H wrote:
> Op Sun, 18 Feb 2007 19:34:57 +0000, schreef raj:
>
>> I've got so far with the mail() function but it won't work. Please help.
>> WHere am I going wrong?
> snip
>> mail($to,"Verify Email Address for Hi", $message, $headers);
>
> i am a newbie too, but the second entry i don't understand. Should be st
> like $subject
>

Yes, thats the subject.

You can read more about it at http://www.php.net/manual/en/function.mail.php
in case you haven't already done that.

--

//Aho
Shion [ Mo, 19 Februar 2007 09:53 ] [ ID #1633905 ]

Re: Newbie needs help with mail function

Op Mon, 19 Feb 2007 10:21:07 +0200, schreef Kimmo Laine:

>
> \r = carriage return = sets the cursor at the beginning of the row
> \n = line feed = begins a new line
>
> (By your powers combined, I am Captain Carriage Return And New Line!)
>
> \r\n in a windows system is the character combination that gives you a new
> line to write to. This is different in *nix based system, where only \n is
> needed, the \r is implied. And just to make it fun, this is also different
> in a Mac system, where only \r is needed and \n is implied.

Thanks, its clear now, but....

> So in total we have three different and fun ways for presenting a new line:
> \r\n in Windows
> \n in *nix
> \r in Mac

..... while windows clearly tried to combine best of both worlds, why
still does it terribly suck so much?

--
8-)
Henk Koster jr.
http://www.interinfra.nl/opensource.htm
http://www.xs4all.nl/~qqoopp/kennemlinks.htm
interinfra.haalweg [ Di, 20 Februar 2007 10:53 ] [ ID #1634917 ]

Re: Newbie needs help with mail function

"Koster, H" <interinfra.haalweg [at] localhost.localdomain> wrote in message
news:45dac509$0$339$e4fe514c [at] news.xs4all.nl...
> Op Mon, 19 Feb 2007 10:21:07 +0200, schreef Kimmo Laine:
>
>>
>> \r = carriage return = sets the cursor at the beginning of the row
>> \n = line feed = begins a new line
>>
>> (By your powers combined, I am Captain Carriage Return And New Line!)
>>
>> \r\n in a windows system is the character combination that gives you a
>> new
>> line to write to. This is different in *nix based system, where only \n
>> is
>> needed, the \r is implied. And just to make it fun, this is also
>> different
>> in a Mac system, where only \r is needed and \n is implied.
>
> Thanks, its clear now, but....
>
>> So in total we have three different and fun ways for presenting a new
>> line:
>> \r\n in Windows
>> \n in *nix
>> \r in Mac
>
> .... while windows clearly tried to combine best of both worlds, why
> still does it terribly suck so much?


Windows inherited this behaviour from MS-DOS which was at much lower level
of suckness.

see also: http://www.rfc-editor.org/EOLstory.txt and
http://en.wikipedia.org/wiki/Newline

--
"Ohjelmoija on organismi joka muuttaa kofeiinia koodiksi" - lpk
http://outolempi.net/ahdistus/ - Satunnaisesti päivittyvä nettisarjis
spam [at] outolempi.net | rot13(xvzzb [at] bhgbyrzcv.arg)
Kimmo Laine [ Di, 20 Februar 2007 13:04 ] [ ID #1634920 ]

Re: Newbie needs help with mail function

Op Mon, 19 Feb 2007 10:21:07 +0200, schreef Kimmo Laine:

>
> \r = carriage return = sets the cursor at the beginning of the row
> \n = line feed = begins a new line
>
> (By your powers combined, I am Captain Carriage Return And New Line!)
>
> \r\n in a windows system is the character combination that gives you a new
> line to write to. This is different in *nix based system, where only \n is
> needed, the \r is implied. And just to make it fun, this is also different
> in a Mac system, where only \r is needed and \n is implied.

Thanks, its clear now, but....

> So in total we have three different and fun ways for presenting a new line:
> \r\n in Windows
> \n in *nix
> \r in Mac

..... while windows clearly tried to combine best of both worlds, why
still does it terribly suck so much?

--
8-)
Henk Koster jr.
http://www.interinfra.nl/opensource.htm
http://www.xs4all.nl/~qqoopp/kennemlinks.htm
interinfra.haalweg [ Di, 20 Februar 2007 10:53 ] [ ID #1634935 ]

Re: Newbie needs help with mail function

"Koster, H" <interinfra.haalweg [at] localhost.localdomain> wrote in message
news:45dac509$0$339$e4fe514c [at] news.xs4all.nl...
> Op Mon, 19 Feb 2007 10:21:07 +0200, schreef Kimmo Laine:
>
>>
>> \r = carriage return = sets the cursor at the beginning of the row
>> \n = line feed = begins a new line
>>
>> (By your powers combined, I am Captain Carriage Return And New Line!)
>>
>> \r\n in a windows system is the character combination that gives you a
>> new
>> line to write to. This is different in *nix based system, where only \n
>> is
>> needed, the \r is implied. And just to make it fun, this is also
>> different
>> in a Mac system, where only \r is needed and \n is implied.
>
> Thanks, its clear now, but....
>
>> So in total we have three different and fun ways for presenting a new
>> line:
>> \r\n in Windows
>> \n in *nix
>> \r in Mac
>
> .... while windows clearly tried to combine best of both worlds, why
> still does it terribly suck so much?


Windows inherited this behaviour from MS-DOS which was at much lower level
of suckness.

see also: http://www.rfc-editor.org/EOLstory.txt and
http://en.wikipedia.org/wiki/Newline

--
"Ohjelmoija on organismi joka muuttaa kofeiinia koodiksi" - lpk
http://outolempi.net/ahdistus/ - Satunnaisesti päivittyvä nettisarjis
spam [at] outolempi.net | rot13(xvzzb [at] bhgbyrzcv.arg)
Kimmo Laine [ Di, 20 Februar 2007 13:04 ] [ ID #1634936 ]

Re: Newbie needs help with mail function

Op Mon, 19 Feb 2007 10:21:07 +0200, schreef Kimmo Laine:

>
> \r = carriage return = sets the cursor at the beginning of the row
> \n = line feed = begins a new line
>
> (By your powers combined, I am Captain Carriage Return And New Line!)
>
> \r\n in a windows system is the character combination that gives you a new
> line to write to. This is different in *nix based system, where only \n is
> needed, the \r is implied. And just to make it fun, this is also different
> in a Mac system, where only \r is needed and \n is implied.

Thanks, its clear now, but....

> So in total we have three different and fun ways for presenting a new line:
> \r\n in Windows
> \n in *nix
> \r in Mac

..... while windows clearly tried to combine best of both worlds, why
still does it terribly suck so much?

--
8-)
Henk Koster jr.
http://www.interinfra.nl/opensource.htm
http://www.xs4all.nl/~qqoopp/kennemlinks.htm
interinfra.haalweg [ Di, 20 Februar 2007 10:53 ] [ ID #1634959 ]

Re: Newbie needs help with mail function

"Koster, H" <interinfra.haalweg [at] localhost.localdomain> wrote in message
news:45dac509$0$339$e4fe514c [at] news.xs4all.nl...
> Op Mon, 19 Feb 2007 10:21:07 +0200, schreef Kimmo Laine:
>
>>
>> \r = carriage return = sets the cursor at the beginning of the row
>> \n = line feed = begins a new line
>>
>> (By your powers combined, I am Captain Carriage Return And New Line!)
>>
>> \r\n in a windows system is the character combination that gives you a
>> new
>> line to write to. This is different in *nix based system, where only \n
>> is
>> needed, the \r is implied. And just to make it fun, this is also
>> different
>> in a Mac system, where only \r is needed and \n is implied.
>
> Thanks, its clear now, but....
>
>> So in total we have three different and fun ways for presenting a new
>> line:
>> \r\n in Windows
>> \n in *nix
>> \r in Mac
>
> .... while windows clearly tried to combine best of both worlds, why
> still does it terribly suck so much?


Windows inherited this behaviour from MS-DOS which was at much lower level
of suckness.

see also: http://www.rfc-editor.org/EOLstory.txt and
http://en.wikipedia.org/wiki/Newline

--
"Ohjelmoija on organismi joka muuttaa kofeiinia koodiksi" - lpk
http://outolempi.net/ahdistus/ - Satunnaisesti päivittyvä nettisarjis
spam [at] outolempi.net | rot13(xvzzb [at] bhgbyrzcv.arg)
Kimmo Laine [ Di, 20 Februar 2007 13:04 ] [ ID #1634970 ]
PHP » alt.php » Newbie needs help with mail function

Vorheriges Thema: gd2 - text rotation
Nächstes Thema: Mail function sends to gmail but not hotmail. Please help (newbie)