PHP Mail help

focus

Member
Messages
128
Reaction score
0
Points
16
I can get my script to send an email but after it sends it the user gets a confirmation "Your mail was sent successfully." on the next page.
THe problem is that the text that the PRINT is displayed in doesn't match the websites CSS its simply in black. How can i fix this?

Webpage:
http://squidg.x10hosting.com/peterstavrou/contact.html

PHP CODE:

<?php


function is_valid_email($from_email)
{
return preg_match('#^[a-z0-9.!\#$%&\'*+-/=?^_`{|}~]+@([0-9.]+|([^\s\'"<>]+\.+[a-z]{2,6}))$#si', $from_email);
}



$to_email = "blabla@hotmail.com";
$subject = "Portfolio Enquiry";
$name.=$_POST['name']."\n" ;
$company.=$_POST['company']."\n" ;
$from_email.=$_POST['email'] ."\n" ;
$msg.=$_POST['msg']."\n" ;


$message = "



Name:
$name

Company:
$company

Email:
$from_email

Message:
$msg




";


$sent = mail($to_email, $subject, $message) ;
if($sent)
{print "Your mail was sent successfully."; }

else
{print "We encountered an error sending your mail"; }

?>



Also... Under the $message = section, how do i get the name for example to be displayed in bold?
For example...

<b> Name: </b>
$name

(but that doesn't work)
 
Last edited:

zapzack

New Member
Messages
606
Reaction score
19
Points
0
1. Edit out your email so spammers dont find it off these forums.
2. Please use php tags around the code.
3. You can echo the variables to other areas in the html like this..
Code:
<body>
<h1>Thanks, <?php echo($name); ?>. Your message has been sent successfully.</h1>
</body>
 

ichwar

Community Advocate
Community Support
Messages
1,454
Reaction score
7
Points
0
You need to use echo instead of print.
 

focus

Member
Messages
128
Reaction score
0
Points
16
Thanks. It's better now :)

How about this bit:

$message = "

Name:
$name

Company:
$company

Email:
$from_email

Message:
$msg

How can i send that to email using HTML display?
For example:

<b>Name:</b>
$name
 

jtwhite

Community Advocate
Community Support
Messages
1,381
Reaction score
30
Points
0
You can't just throw variables in there. You'll need to do it like this:

PHP:
$message = "

Name:
  " . $name . "

Company:
" . $company . "

Email:
" . $from_email . "

Message:
" . $msg . "

";

Read this for information on sending HTML mail: http://us.php.net/manual/en/function.mail.php
 
Last edited:
Top