PDA

View Full Version : PHP and email - simple problem..



crunchysocks
September 18th, 2005, 11:21 AM
i think...

I did this tutorial

http://www.kirupa.com/developer/act...h_php_email.htm (../developer/actionscript/flash_php_email.htm)

And it almost did what i wanted, but in the email it sends you, it looked like this:

<TEXTFORMAT LEADING=\"2\"><P ALIGN=\"LEFT\"><FONT FACE=\"Times New Roman\" SIZE=\"15\" COLOR=\"#17130A\" LETTERSPACING=\"0\" KERNING=\"0\"></FONT></P></TEXTFORMAT>

Cut a lot of it out.

This is my php code



<?php
$sendTo = "crunchysocks@gmail.com";
$subject = "SFStudios reply";

$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$headers = "From: " . $_POST["name"];
$headers .= "<" . $_POST["email"] . ">\r\n";
$headers .= "Reply-To: " . $_POST["email"] . "\r\n";
$headers .= "Return-Path: " . $_POST["email"];



// For new lines use this
$addressbar."<br>".$website."<br>".$phone."<br>".$comments;

mail($sendTo, $subject, $message, $headers);

?>


And so basicly i just want it to format itself nicely...

Like have a heading saying

From: (IN BOLD)
Scott

Email:
This@that.there

Please help, this is driving me nuts

Thanks! :D

Pasquale
September 18th, 2005, 06:14 PM
Well this is what i use

<?
if(!empty($HTTP_POST_VARS['sender_mail']) || !empty($HTTP_POST_VARS['sender_message']) || !empty($HTTP_POST_VARS['sender_subject']) || !empty($HTTP_POST_VARS['sender_name']))
{
$to = "pgdsilva@gmail.com";
$subject = stripslashes($HTTP_POST_VARS['sender_subject']);
$body = stripslashes($HTTP_POST_VARS['sender_message']);
$body .= "\n\n---------------------------\n";
$body .= "Mail sent by: " . $HTTP_POST_VARS['sender_name'] . " <" . $HTTP_POST_VARS['sender_mail'] . ">\n";
$header = "From: " . $HTTP_POST_VARS['sender_name'] . " <" . $HTTP_POST_VARS['sender_mail'] . ">\n";
$header .= "Reply-To: " . $HTTP_POST_VARS['sender_name'] . " <" . $HTTP_POST_VARS['sender_mail'] . ">\n";
$header .= "X-Mailer: PHP/" . phpversion() . "\n";
$header .= "X-Priority: 1";
if(@mail($to, $subject, $body, $header))
{
echo "output=sent";
} else {
echo "output=error";
}
} else {
echo "output=error";
}
?>

This is a form in flash though, but look at the format. Im not too good with PHP but i can fix basic things up to suit my needs

crunchysocks
September 18th, 2005, 09:40 PM
hey thanks for replying,

yeh i'm no good with php either, i just used the code from the tutorial, and altered it from various sources...

With yours, how do you implement it into flash?

Thanks for your help :)

minimaldesign
September 18th, 2005, 11:57 PM
if I understand your problem correctly, you'd like to get rid off the HTML part of the messages right? This might do the trick, just add this before the code that sends the mail but after the code that assigns the value to $message.


$message = strip_tags($message);

hope that helps :)

crunchysocks
September 19th, 2005, 06:06 AM
Hey

Thats more what i wanted, except now all i get in the actual email is the 'message' part they sent... in the subject or something it has all this crap, containing their name and email...

I'm getting there!

minimaldesign, thanks for your help so far, just need a little more tweaking :D

I owe you one mate ;)

minimaldesign
September 19th, 2005, 08:30 AM
Thats more what i wanted, except now all i get in the actual email is the 'message' part they sent...
I thought that's what you wanted. What are you trying to do exactly? Not sure I get it...


in the subject or something it has all this crap.

If you wanna be more "specific," maybe I can try to help ;)

crunchysocks
September 19th, 2005, 09:09 AM
Sorry yeh :)

Well, I have 3 boxes they fill out (which by the way are not working when uploaded to my server, you can type in them, but you cant see the text, yet another problem).. anyway, the user must fill out their name, email, and message.

Currently, when i click send i only the message body come in the email..

Do you have msn messenger by chance ? ;)

crunchysocks
September 19th, 2005, 09:18 AM
the subject no longer has the crap, now it has my servers email address (which was put in via php code to avoid the spam filter)..

minimaldesign
September 19th, 2005, 11:23 AM
Sorry yeh :)

Well, I have 3 boxes they fill out (which by the way are not working when uploaded to my server, you can type in them, but you cant see the text, yet another problem).. anyway, the user must fill out their name, email, and message.

Currently, when i click send i only the message body come in the email..

Do you have msn messenger by chance ? ;)

well, not sure why only the $message would work. The only funky thing I see in your code is your $headers assignation, not sure what you're trying to do with those 4 consecutive lines... You could just have it something like (that's unrelated to your problem though):


$headers = "From: " .$_POST["name"]."<".$_POST["email"].">\r\n"."Reply-To: ".$_POST["email"]."\r\n"."Return-Path: ".$_POST["email"];


The problem probably comes from the way the variable values are passed within the form itself since $message works.

no IM - sorry ;)

G
October 7th, 2005, 03:24 AM
Simple fix...I'll do a more advanced one if you want when I get home just send me a PM.



if(name_txt.text != "" && message_txt.text != && email_txt.text != "") {
//process form
} else {
//user has not filled all input fields
}