473,324 Members | 2,124 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

i need help with my mail script

dear all,

i have started learning php 2 weeks ago and i have wrote my first
script for mail sender and the script takes all my data and move to
the thanks page but the problem is that the mails never comes, so i
need your help with me, and here is my script:

mail.htm code:

<form method="POST" action="mail.php" onSubmit="">
<p>email <input type="text" name="email" size="20"></p>
<p>subject <input type="text" name="subject"></p>
<p>message<textarea rows="2" name="message" cols="20"></textarea></
p>
<p><input type="submit" value="Submit" name="B1"><input type="reset"
value="Reset" name="B2"></p>
</form>
mail.php code:

<?php
$email = $HTTP_POST_VARS['email'];
$subject = $HTTP_POST_VARS['subject'];
$msg = $HTTP_POST_VARS['message'];
$from = "s7els7.com";
if (mail($email,$subject,$message,$from)) {
echo "<h4>Thank you for sending email</h4>";
} else {
echo "<h4>Can't send email to $mail</h4>";
}
?>
now please tell me whats wrong with this scripts as i am still trying
to learn the php and i need an expert help.
you can check my script working at www.s7els7.com/mail.htm

thanks

shror

Feb 19 '07 #1
4 1947
"shror" <sh******@gmail.comwrote in news:1171898875.188006.234860
@p10g2000cwp.googlegroups.com:
dear all,

i have started learning php 2 weeks ago and i have wrote my first
script for mail sender and the script takes all my data and move to
the thanks page but the problem is that the mails never comes, so i
need your help with me, and here is my script:

mail.htm code:

<form method="POST" action="mail.php" onSubmit="">
You don't need the onSubmit attribute if there is nothing to do
<p>email <input type="text" name="email" size="20"></p>
<p>subject <input type="text" name="subject"></p>
<p>message<textarea rows="2" name="message" cols="20"></textarea></
p>
<p><input type="submit" value="Submit" name="B1"><input type="reset"
value="Reset" name="B2"></p>
</form>
mail.php code:

<?php
$email = $HTTP_POST_VARS['email'];
$subject = $HTTP_POST_VARS['subject'];
$msg = $HTTP_POST_VARS['message'];
You want to use the $_POST superglobal array here not the old
$HTTP_POST_VARS array.

$email = $_POST['email'];
$subject = $_POST['subject'];
$msg = $_POST['message'];

$from = "s7els7.com";
The "From" header needs to be formated correctly:
"From: va***@emai.address.here";

$from = "From: yo*************@s7els7.com";
if (mail($email,$subject,$message,$from)) {
echo "<h4>Thank you for sending email</h4>";
} else {
echo "<h4>Can't send email to $mail</h4>";
}
?>
Leaving your script like this, you are opening yourself up to spammers
finding your form and using it to do all sorts of spamming.

You should read this
<http://www.nyphp.org/phundamentals/email_header_injection.phparticle
on preventing Email Header Injection Exploits.

Ken
Feb 19 '07 #2
Hi Ken,
First of all i'd like to thank you so much for offering me help

then about the onsubmit i have removed it now

and in the mail.php page i have made some changes as you told me
the new code is:

<?php
$email = $_POST['email'];
$subject = $_POST['subject'];
$message = $_POST['message'];
$from = "From: em***@s7els7.com";
$t = "shahirwm";
$o = "@gmail.com";
$to = $t . $o;
if (mail($email,$subject,$message,$from,$to)) {
echo "<h4>Thank you $email for sending $to this email</h4>";
} else {
echo "<h4>Can't send email to $email</h4>";
}
?>
i have made the $from as you said and almost every thing but still i
cant get any mails from this script so please help me once more how to
fix it and where is my problem.
thanks once more for your help
the form URL is: www.s7els7.com/mail.htm

Feb 19 '07 #3
I think there is a mistake in your arguments. From the manual, the
order is:

bool mail ( string $to, string $subject, string $message [, string
$additional_headers [, string $additional_parameters]] )

Why do you pass $email as your first argument and $to as your last
argument? I suggest trying mail($to,$subject,$message,$from) first.

Another thing to check is your PHP mail configuration, if you are
running your own server. The details are in the PHP manual:
http://www.php.net/manual/en/ref.mail.php. But this applies if you are
running PHP off your own computer.

On Feb 20, 7:11 am, "shror" <shahi...@gmail.comwrote:
Hi Ken,
First of all i'd like to thank you so much for offering me help

then about the onsubmit i have removed it now

and in the mail.php page i have made some changes as you told me
the new code is:

<?php
$email = $_POST['email'];
$subject = $_POST['subject'];
$message = $_POST['message'];
$from = "From: e...@s7els7.com";
$t = "shahirwm";
$o = "@gmail.com";
$to = $t . $o;
if (mail($email,$subject,$message,$from,$to)) {
echo "<h4>Thank you $email for sending $to this email</h4>";} else {

echo "<h4>Can't send email to $email</h4>";}

?>

i have made the $from as you said and almost every thing but still i
cant get any mails from this script so please help me once more how to
fix it and where is my problem.

thanks once more for your help
the form URL is:www.s7els7.com/mail.htm

Feb 20 '07 #4
On Feb 20, 6:11 am, "Klarth" <kah....@gmail.comwrote:
I think there is a mistake in your arguments. From the manual, the
order is:

bool mail ( string $to, string $subject, string $message [, string
$additional_headers [, string $additional_parameters]] )

Why do you pass $email as your first argument and $to as your last
argument? I suggest trying mail($to,$subject,$message,$from) first.

Another thing to check is your PHP mail configuration, if you are
running your own server. The details are in the PHP manual:http://www.php.net/manual/en/ref.mail.php. But this applies if you are
running PHP off your own computer.

On Feb 20, 7:11 am, "shror" <shahi...@gmail.comwrote:
Hi Ken,
First of all i'd like to thank you so much for offering me help
then about the onsubmit i have removed it now
and in the mail.php page i have made some changes as you told me
the new code is:
<?php
$email = $_POST['email'];
$subject = $_POST['subject'];
$message = $_POST['message'];
$from = "From: e...@s7els7.com";
$t = "shahirwm";
$o = "@gmail.com";
$to = $t . $o;
if (mail($email,$subject,$message,$from,$to)) {
echo "<h4>Thank you $email for sending $to this email</h4>";} else {
echo "<h4>Can't send email to $email</h4>";}
?>
i have made the $from as you said and almost every thing but still i
cant get any mails from this script so please help me once more how to
fix it and where is my problem.
thanks once more for your help
the form URL is:www.s7els7.com/mail.htm- Hide quoted text -

- Show quoted text -
Thank you Klarth for your note, it was correct and it fixed my form,
now its working fine, but i just need one more thing which is how i
set the X-mailer to be someting i do configer, is it possible or not
thanks so much for your help once more and for the help of every body.

shror

Feb 21 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: DonLi | last post by:
Hello, I tested a PHP script with a FORM of 2 element and it delivered the mail but then when I added more FORM elements, it failed to deliver. Following is the content of the PHP script that...
9
by: Jofio | last post by:
I am just learning PHP. I just tried coding a php script which I saved as mail.php ---------------------------- <? $name=$_POST; $email=$_POST; $comments=$_POST;
0
by: James Hong | last post by:
Help please, I try to sending an email from my html page using the java applet. but it give error on most of the PC only very few work, what is the error i make the java applet show as below ...
5
by: Bernard | last post by:
Hi, I have a problem with a CGI script (Perl) on a Win2000 server. The script is for sending E-cards and was written by Jason Maloney:...
2
by: Mr. x | last post by:
Hello, I am sending emails with Hebrew contents. When receiving emails - I cannot see the Hebrew characters (it is not outlook express configuration, because when receiving emails from friends -...
20
by: Pete Marsh | last post by:
Wondering if anyone can see an error with this script. I get a server configuration error. THat could mean a module is not being loaded, but maybe there's a syntax error here, can anyone spot it?...
0
by: josh | last post by:
HI I'm new to .asp and vbscript and I need to validate a form before it is emailed to me. I don't really understand what email functionality I have on the server (and the tech support might get...
11
by: shror | last post by:
Hi every body, Please I need your help solving my php mail() function problem that the code is appearing in the view source and I dont know whats the problem where I am using another page tto test...
5
by: simononestop | last post by:
Hi im totally new to perl this is my first go at using it (I normally use asp). I have set up a form with a cgi script from demon hosting. I have edited the script and the form works it sends me an...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.