DeveloperSide.NET Forums
October 15, 2019, 04:45:57 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Message fileld in PHP mail function  (Read 12355 times)
0 Members and 1 Guest are viewing this topic.
DrT
Member
*
Posts: 3


View Profile
« 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.


Logged
admin
Administrator
Master of All Subjects
*****
Posts: 3272


View Profile WWW Email
« Reply #1 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);
Logged

DeveloperSide.NET
Advanced PHP and MySQL Solutions for your Web Design and Development needs with Web.Developer Server Suite.
DrT
Member
*
Posts: 3


View Profile
« Reply #2 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.



Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.9 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!