this is my contact form.html -
<form id="contacts-form" method="post" action="mail.php" onSubmit="return validateForm(this)">
-
<fieldset>
-
<div class="field"><label>Full Name:</label><input type="text" value="" name="name"/> <font color="#FF0000" size="+1">*</font></div>
-
<div class="field"><label>E-mail:</label><input type="text" value="" name="email"/> <font color="#FF0000" size="+1">*</font></div>
-
<div class="field"><label>Phone:</label><input type="text" value="" name="phone"/> <font color="#FF0000" size="+1"></font></div>
-
<div class="field"><label>Subject:</label><input type="text" value="" name="subject"/></font></div>
-
-
<div class="field"><label>Services:</label><select name="services">
-
<option>------------Select------------</option>
-
<option>Call Center Services</option>
-
<option>Data Entry Services</option>
-
<option>KPO Services</option>
-
<option>Health Care Services</option>
-
<option>Software Development</option>
-
</select>
-
<font color="#FF0000" size="+1">*</font>
-
</div>
-
<div class="field"><label>Message:</label><textarea name="message" cols="" rows=""></textarea> </div>
-
-
<div align="center"><input type="submit" value="SUBMIT"/></font></div>
-
-
<!--<div class="alignright"><a href="mail.php" class="button" onclick="document.getElementById('contacts-form').submit()"><em><b>Submit</b></em></a>
-
</div>-->
-
</fieldset>
-
</form>
-
-
this is my mail.php -
<?php
-
//if(isset($_POST['email'])) {
-
-
-
$email_to = "lark.imp@gmail.com "; //mail id
-
$email_subject = "Outsource Projects to India";
-
-
-
$name = $_POST['name'];
-
$email = $_POST['email'];
-
$phone = $_POST['phone'];
-
$services = $_POST['services'];
-
$message = $_POST['message'];
-
-
-
$error_message = "";
-
-
$email_message = "Form details below.\n\n";
-
-
function clean_string($string) {
-
$bad = array("content-type","bcc:","to:","cc:","href");
-
return str_replace($bad,"",$string);
-
//}
-
-
$email_message .= "Name: ".clean_string($name)."\n";
-
$email_message .= "Email: ".clean_string($email)."\n";
-
$email_message .= "Phone: ".clean_string($phone)."\n";
-
$email_message .= "Services: ".clean_string($services)."\n";
-
$email_message .= "Message: ".clean_string($message)."\n";
-
-
-
// create email headers
-
$headers = 'From: '.$email."\r\n".
-
'Reply-To: '.$email."\r\n" .
-
'X-Mailer: PHP/' . phpversion();
-
@mail($email_to, $email_subject, $email_message, $headers);
-
?>
-
<?php
-
}
-
?>
-
is ther anything wrong? plz help
18 3061
you could say the @ is wrong, as it prevents you to receive any errors mail() may encounter. you also don’t check mail()’s return value to see if the call was successful.
ya. i tested with the script, when i click submit it goes to the thank you page without any error. but i am not recieving any mails...
you cannont get any errors, because you suppress them.
oh, then what i have to do?
i tried with different script..
this is my form. -
<form name="contactform" method="post" action="send_form_email.php">
-
<table width="450px">
-
</tr>
-
<tr>
-
<td valign="top">
-
<label for="first_name">First Name *</label>
-
</td>
-
<td valign="top">
-
<input type="text" name="first_name" maxlength="50" size="30">
-
</td>
-
</tr>
-
-
<tr>
-
<td valign="top">
-
<label for="last_name">Last Name *</label>
-
</td>
-
<td valign="top">
-
<input type="text" name="last_name" maxlength="50" size="30">
-
</td>
-
</tr>
-
<tr>
-
<td valign="top">
-
<label for="email">Email Address *</label>
-
</td>
-
<td valign="top">
-
<input type="text" name="email" maxlength="80" size="30">
-
</td>
-
-
</tr>
-
<tr>
-
<td valign="top">
-
<label for="telephone">Telephone Number</label>
-
</td>
-
<td valign="top">
-
<input type="text" name="telephone" maxlength="30" size="30">
-
</td>
-
</tr>
-
<tr>
-
<td valign="top">
-
<label for="comments">Comments *</label>
-
</td>
-
<td valign="top">
-
<textarea name="comments" maxlength="1000" cols="25" rows="6"></textarea>
-
</td>
-
-
</tr>
-
<tr>
-
<td colspan="2" style="text-align:center">
-
<input type="submit" value="Submit"> <a href="http://www.freecontactform.com/email_form.php">Email Form</a>
-
</td>
-
</tr>
-
</table>
-
</form>
-
-
this is my send_form_email.php -
<?php
-
if(isset($_POST['email'])) {
-
-
// EDIT THE 2 LINES BELOW AS REQUIRED
-
$email_to = "impin@in.com.com";
-
$email_subject = "Your email subject line";
-
-
-
function died($error) {
-
// your error code can go here
-
echo "We are very sorry, but there were error(s) found with the form your submitted. ";
-
echo "These errors appear below.<br /><br />";
-
echo $error."<br /><br />";
-
echo "Please go back and fix these errors.<br /><br />";
-
die();
-
}
-
-
// validation expected data exists
-
if(!isset($_POST['first_name']) ||
-
!isset($_POST['last_name']) ||
-
!isset($_POST['email']) ||
-
!isset($_POST['telephone']) ||
-
!isset($_POST['comments'])) {
-
died('We are sorry, but there appears to be a problem with the form your submitted.');
-
}
-
-
$first_name = $_POST['first_name']; // required
-
$last_name = $_POST['last_name']; // required
-
$email_from = $_POST['email']; // required
-
$telephone = $_POST['telephone']; // not required
-
$comments = $_POST['comments']; // required
-
-
$error_message = "";
-
$email_exp = "^[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$";
-
if(!eregi($email_exp,$email_from)) {
-
$error_message .= 'The Email Address you entered does not appear to be valid.<br />';
-
}
-
$string_exp = "^[a-z .'-]+$";
-
if(!eregi($string_exp,$first_name)) {
-
$error_message .= 'The First Name you entered does not appear to be valid.<br />';
-
}
-
if(!eregi($string_exp,$last_name)) {
-
$error_message .= 'The Last Name you entered does not appear to be valid.<br />';
-
}
-
if(strlen($comments) < 2) {
-
$error_message .= 'The Comments you entered do not appear to be valid.<br />';
-
}
-
$string_exp = "^[0-9 .-]+$";
-
if(!eregi($string_exp,$telephone)) {
-
$error_message .= 'The Telphone Number you entered does not appear to be valid.<br />';
-
}
-
if(strlen($error_message) > 0) {
-
died($error_message);
-
}
-
$email_message = "Form details below.\n\n";
-
-
function clean_string($string) {
-
$bad = array("content-type","bcc:","to:","cc:","href");
-
return str_replace($bad,"",$string);
-
}
-
-
$email_message .= "First Name: ".clean_string($first_name)."\n";
-
$email_message .= "Last Name: ".clean_string($last_name)."\n";
-
$email_message .= "Email: ".clean_string($email_from)."\n";
-
$email_message .= "Telephone: ".clean_string($telephone)."\n";
-
$email_message .= "Comments: ".clean_string($comments)."\n";
-
-
-
// create email headers
-
$headers = 'From: '.$email_from."\r\n".
-
'Reply-To: '.$email_from."\r\n" .
-
'X-Mailer: PHP/' . phpversion();
-
mail($email_to, $email_subject, $email_message, $headers);
-
?>
-
-
<!-- include your own success html here -->
-
-
Thank you for contacting us. We will be in touch with you very soon.
-
-
<?php
-
}
-
?>
-
-
i get the message "Thank you for contacting us. We will be in touch with you very soon.". but i wont receive any mails....
i tried with a simple form -
<form action="exmail.php" method="POST">
-
<b>Email</b><br>
-
<input type="text" name="email" size=40>
-
<p><b>Subject</b><br>
-
<input type="text" name="subject" size=40>
-
<p><b>Message</b><br>
-
<textarea cols=40 rows=10 name="message"></textarea>
-
<p><input type="submit" value=" Send ">
-
</form>
-
this is my simple php script -
<?php
-
-
/* All form fields are automatically passed to the PHP script through the array $HTTP_POST_VARS. */
-
$email = $_POST['email'];
-
$subject = $_POST['subject'];
-
$message = $_POST['message'];
-
-
/* PHP form validation: the script checks that the Email field contains a valid email address and the Subject field isn't empty. preg_match performs a regular expression match. It's a very powerful PHP function to validate form fields and other strings - see PHP manual for details. */
-
if (!preg_match("/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/", $email)) {
-
echo "<h4>Invalid email address</h4>";
-
echo "<a href='javascript:history.back(1);'>Back</a>";
-
} elseif ($subject == "") {
-
echo "<h4>No subject</h4>";
-
echo "<a href='javascript:history.back(1);'>Back</a>";
-
}
-
-
/* Sends the mail and outputs the "Thank you" string if the mail is successfully sent, or the error string otherwise. */
-
elseif (mail($email,$subject,$message)) {
-
echo "<h4>Thank you for sending email</h4>";
-
} else {
-
echo "<h4>Can't send email to $email</h4>";
-
}
-
?>
-
i get result as " Can't send email to <email address>".
i dont what the problem is?
i just upload the script into my website and tested...
when i test the script in my local it shows the error
" Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set()"
.
what shall i do? plz help...
this is my php.ini file. -
-
[mail function]
-
; For Win32 only.
-
; http://php.net/smtp
-
SMTP = localhost
-
; http://php.net/smtp-port
-
smtp_port = 25
-
-
; For Win32 only.
-
; http://php.net/sendmail-from
-
sendmail_from = you@yourdomain
-
-
i hav to change anything here?
looks sensible, though …
do you have a smtp service running in windows?
i dont know about that. my doubt is, when my website is online each user access from different systems, that means each system must have the smtp service?
its very confusing... i am sorry i am new to this...
nope, php looks for an smtp service on the computer, PHP is installed on, i.e. the host computer (yours)
that means that php installed computer must have smtp service then only the mail script will work when we upload it into the website...?
what i have done is...
its a simple php script. i wrote script in notepad and save it as mail.php and i just upload it into my website... in my system i didnt install php.
that means that php installed computer must have smtp service then only the mail script will work when we upload it into the website...?
that depends on the OS of the webserver that’s hosting the script. *NIX type OS only require the sendmail library.
oh that means the webserver must support smtp services right?
no. only windows servers must.
oh. so what should i do? should i contact the web host providers? they are the one's should know about this? or else i have to do something in myside?
now my website is online. but the mails only not going... -
if (mail($email_to, $email_subject, $email_message, $headers))
-
{
-
echo "<h4>Thank you for sending email</h4>";
-
} else {
-
echo "<h4>Can't send email</h4>";
-
}
-
?>
-
i get result as "i cant send email".
should i contact the web host providers?
yes .
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Jim Seymour |
last post by:
I have a contact form that uses PHP's mail() function. It recently
came to my attention that (some?) MS-Windows mail servers may not
properly process data given to the mail() function that's only...
|
by: Data Goob |
last post by:
This one has me stumped.
How did SuSE disable the mail() function in their RPM'd version of PHP?
( This is their install-version of PHP with RPMs not what you download
from PHP.net )
I have...
|
by: tzuccolo2001 |
last post by:
I'm trying to send an email using the mail() function. I've carefully
made use of the ini_set(SMTP, "mail.my.server") function to set my SMTP
server and also to set my From: address. I'm still...
|
by: chris.huh |
last post by:
I have setup Apache and PHP on my local machine as a testing server. So
to test the mail() function i have set the SMTP_host thing in php.ini
to what i think is the hotmail SMTP server.
Whenever...
|
by: Bandul |
last post by:
Hi everyone
I am trying to send a e-mail using the mail() function.
Now i try to send more than one data from mysql database so i must use
example
$results=mysql_num_rows($result_query)...
|
by: Lieven |
last post by:
Hey,
I had a hard disc problem last week on my server. I replaced the disc and
copied al the files to the new hard disc, everything works fine again except
some php scripts that are using the...
|
by: maya |
last post by:
I'm learning how to send mail with php...
only thing that mystifies me a bit is I can't get NAME of sender to
appear in e-mail INBOX under "from"... I only see e-mail address.. I'm
coming from...
|
by: shror |
last post by:
hi every body,
i have a problem which is when i was checking my mail() form it work
fine but the problem is that the form configuration is not set
correctly, in details:
the from var is not...
|
by: anandaraman |
last post by:
Hi all, i want to send mail through php coding.but error displays. i am working in windows environment. please help..
PHP Coding:
<?php
$to = "anandh@yahoo.com";
$subject = "Example";
$txt =...
|
by: prabirchoudhury |
last post by:
mail() function stopped working after server upgraded to php 4.4.4. not getting any error on server error-log file and the php page . any idea please.
using mail function code
$to =...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
| |