View Full Version : PHP Code Help, Please.
David REMD
06-25-2007, 12:25 PM
I have posted the following mail.php file to my website:
<?php
// send our email
mail ("$to","$subject","$body","$from");
?>
Here is my input and HTTP.submit:
-- Get values from input fields
name = Input.GetText("name");
email_address = Input.GetText("email_address");
email_subject = Input.GetText("subject");
message = Input.GetText("message");
from = noreply@domain.com;
to = email@domain.com;
[CODE]-- body of email message
body = "Name: "..name.."\r\nEmail Address: "..email_address.."\r\nMessage: "..message..";
-- subject line of email message
subject = ..email_subject;
-- submit message to mail.php
HTTP.Submit("http://www.domain.com/mail.php,(to=to,subject=subject,body=body,from=fro m), _POST, 20, 80, nil, nil);
The "From" shows up in the body of the email as opposed to the "From (Sender)". Can someone help with the mail.php script, please?
Try these changes. The changes are noted in red text:
from = "noreply@domain.com";
to = "email@domain.com";
HTTP.Submit("http://www.domain.com/mail.php,{to=to,subject=subject,body=body,from=fro m}, SUBMITWEB_POST, 20, 80, nil, nil);
David REMD
06-25-2007, 01:46 PM
Tek,
I made the changes and the senders email address appears like this:
Apache [apache@snake.tera-byte.com]
I have the site hosted with tera-byte.com.
The from = "email@domain.com"; appears on the first line in the body of the message as:
email@domain.com
What script would I need to add to the mail.php file in order to replace Apache [apache@snake.tera-byte.com] with email@domain.com?
Our company uses tera-byte.com hosting as well and (as far as I know) the email will appear to come from the account name of the site. I don't know if this can be changed unless something can be done in your php.ini file for your hosting account.
David REMD
06-25-2007, 02:42 PM
I spoke to their support people today, and they said it was possible to change it, and that it would need to be via the mail.php script. I'm looking the script I could add to the mail.php to make it happen. Anybody?
In that case try adding this line before your mail function in your php file:
$from = "noreply@domain.com";
David REMD
06-26-2007, 08:44 AM
I tried and get the same result. Apache [apache@snake.tera-byte.com] is still showing up as the sender.
You can see why I want to modify the sender. "Apache" and "snake" in the sender name are not exactly comforting terms to a mail recipient.
I received another response to my help ticket, and they said it can be done. However, it does need to be done in the mail.php script. Does anyone have a script that deals with this issue?
JXBURNS
06-26-2007, 10:22 AM
Have a look at this - I use it all the time and works brilliantly.
http://www.dagondesign.com/articles/secure-php-form-mailer-script/
Rgds John
David REMD
06-26-2007, 11:05 AM
I was able to get the following script to work:
<?php $sendTo = "$to";
$subject = "$subject";
$headers = "From: noreply@domain.com" ;
$headers .= "<noreply@domain.com>\r\n";
$headers .= "Reply-To: Do Not Reply";
$message = "$message";
mail($sendTo, $subject, $message, $headers);?>
I hope this helps others!
And, thanks to all that responded :yes !
rexzooly
09-18-2007, 04:00 AM
I was able to get the following script to work:
<?php $sendTo = "$to";
$subject = "$subject";
$headers = "From: noreply@domain.com" ;
$headers .= "<noreply@domain.com>\r\n";
$headers .= "Reply-To: Do Not Reply";
$message = "$message";
mail($sendTo, $subject, $message, $headers);?>
I hope this helps others!
And, thanks to all that responded :yes !
<?php
$sig=$HTTP_GET_VARS["sig"];
$sendTo="Rexzooly@vilsoft.co.uk";
$subject = $HTTP_GET_VARS["sb"];
$headers = "From: User: $sig " ;
$headers .= "<noreply@diskhub.info>\r\n";
$headers .= "You Was Contacted By:\r\n";
$headers .= $HTTP_GET_VARS["from"];
$message = $HTTP_GET_VARS["body"];
mail($sendTo, $subject, $message, $headers);?>
I am trying to get the Signature to be in the from field and the bottem of
the body also does anyone know how to do this?
rexzooly
09-18-2007, 05:24 AM
<?php
$sig=$HTTP_GET_VARS["sig"];
$sendTo="Rexzooly@vilsoft.co.uk";
$subject = $HTTP_GET_VARS["sb"];
$headers = ".$sig." ;
$headers .= "<noreply@diskhub.info>\r\n";
$headers .= "You Was Contacted By:\r\n";
$headers .= $HTTP_GET_VARS["from"];
$message = $HTTP_GET_VARS["body"];
mail($sendTo, $subject, $message, $headers);?>
I am trying to get the Signature to be in the from field and the bottem of
the body also does anyone know how to do this?
or is it a problem with my code ?
-- clear error variable
error = 0;
-- Get values from input fields
from = Input.GetText("Input1");
subject = Input.GetText("Input2");
body = Input.GetText("Input3");
sig = Input.GetText("Input4");
-- Submit To Server
tSubmitValues = {
sb = subject;
body = body;
from = from;
sig = footer;
}
-- check for empty fields and deliver errors if needed
if String.Length(sig) < 1 then
Dialog.Message("Error", " enter Signature Thank you.");
error = 1;
end
if String.Length(from) < 1 then
Dialog.Message("Error", "Please enter your email address and re-submit. Thank you.");
error = 1;
end
if String.Length(subject) < 1 then
Dialog.Message("Error", "Please enter your email subject and re-submit. Thank you.");
error = 1;
end
if String.Length(body) < 1 then
Dialog.Message("Error", "Please enter your email message and re-submit. Thank you.");
error = 1;
end
if error~=1 then
-- if no errors exist, send the email now and give a confirmation dialog
result = HTTP.Submit("http://diskhub.info/mail2.php", tSubmitValues, SUBMITWEB_GET, 1, 80, nil, nil);
Dialog.Message("Submit Confirmation", "The Following Data You Just Sent Is: \r\n" .. result);
Dialog.Message("Thank You", "We Will Get Back To You Shortly\r\n", MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
Page.Jump("Home");
end
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.