DeveloperSide.NET Forums

DeveloperSide.NET => Web.Developer Server Suite Community Edition,
Public Support Forum => Topic started by: DrT on July 19, 2009, 04:46:39 PM



Title: Message fileld in PHP mail function
Post by: DrT on July 19, 2009, 04:46:39 PM
Hi!

As I posted before, I am slowly writing a PHP script for emailing the results of a form. The script is based on a variety of scripts found on the Web.

To do a preliminary test, I wrote the following PHP script:

<?php
$to = $_REQUEST['MyEmail'] ;
$subject = $_REQUEST['subject'] ;
$greeting = $_REQUEST['greeting'] ;
$realname = $_REQUEST['realname'] ;
$HisEmail = $_REQUEST['HisEmail'] ;
$message = $_REQUEST['message'] ;
$headers = "From: $HisEmail";
$send = mail($to, $subject, $greeting, $headers);
?>

It works.

If, in the mail function, I replace $greeting with $realname it also works.

But, if I replace $greeting with $greeting\n$realname it doesn’t work. Why?

Thanks.

Dr. T.




Title: Re: Message fileld in PHP mail function
Post by: admin on July 19, 2009, 05:15:08 PM
Quote
But, if I replace $greeting with $greeting\n$realname it doesn’t work. Why?

Can you give an example of the code you are using? It sounds like you might have a php syntax issue...
This will not work: $send = mail($to, $subject, $greeting\n$realname, $headers);

You would have to do something like this instead:
$greeting2 = $greeting . "\n" . $realname ;
$send = mail($to, $subject, $greeting2, $headers);


Title: Re: Message fileld in PHP mail function
Post by: DrT on July 21, 2009, 10:45:52 PM
Hi!

Thank you for your reply.

I changed the code as follows:

$send = mail($MyEmail, $subject, 'TITLE: '.$greeting."\n"."\n".'NAME: '.$realname."\n"."\n".'EMAIL: '.$HisEmail."\n"."\n".'MESSAGE: '."\n"."\n".$message, $headers);

It works! :-)

Dr. T.