Yet again I am having more problems. I am having problems sending a message with the mail form using different email addresses in the "e-mail header". If I use my gmail address, the mail form sends the message to the recepient email address but if I use my yahoo or hotmail addresses, the mail form does not send the message to the recepient email though I get a message to say it has been successfully sent. To give an e.g. take this to be my mail form layout with the following:-
name : naseem
e-mail: naseemsadak@gmail.com(my gmail address)
message: your message goes here
now when I click the submit button the message gets sent through but when I use my hotmail or yahoo email address in place of the gmail address, I still get the message to say it's sent but it's not received. I am testing the php script using xampp and the smtp server relay configuration in IIS from the link that helped me to do so http://drupal.org/node/30079 . Here is my mail form code in php:-
Code: Select all
<html>
<body>
<?php
function spamcheck($field)
{
//filter_var() sanitizes the e-mail
//address using FILTER_SANITIZE_EMAIL
$field=filter_var($field, FILTER_SANITIZE_EMAIL);
//filter_var() validates the e-mail
//address using FILTER_VALIDATE_EMAIL
if(filter_var($field, FILTER_VALIDATE_EMAIL))
{
return TRUE;
}
else
{
return FALSE;
}
}
if (IsSet($_REQUEST['email']))
{//if "email" is filled out, proceed
//check if the email address is invalid
$mailcheck = spamcheck($_REQUEST['email']);
if($mailcheck==FALSE)
{
echo "email address is invalid";
}
//send email
else
{
$ToEmail = 'sadak@worldonline.co.za';
$EmailSubject = 'Contact Form ';
$mailheader = "From: ".$_REQUEST['email']."\r\n";
$mailheader .= "Reply-To: ".$_REQUEST['email']."\r\n";
$mailheader .= "Content-type: text/html; charset=iso-8859-1\r\n";
$MESSAGE_BODY .= nl2br($_REQUEST['comment'])."<br>";
if(IsSet($_REQUEST['email']))
{
mail($ToEmail, $EmailSubject, $MESSAGE_BODY, $mailheader);
}
if (!mail($ToEmail, $EmailSubject, $MESSAGE_BODY, $mailheader))
{
echo "Error in sending message. Please ensure details are entered correctly";
}
else
{
echo "Message was successfully sent";
}
}
?>
<?php
}else{
?>
<form action="contactform.php" method="post">
<table><tr>
<td colspan="2" align="center"><b>Contact Us</b><p></td>
</tr><tr>
<td valign="top" align="right" class="bodytext">Name:</td>
<td valign="top"><input name="name" id="name" size="25"></td>
</tr><tr>
<td valign="top" align="right" class="bodytext">E-mail:</td>
<td valign="top"><input name="email" id="email" size="25"></td>
</tr><tr>
<td valign="top" align="right" class="bodytext">Comments:</td>
<td valign="top" overflow="scroll"><textarea name="comment" rows="5" cols="35" id="comment"></textarea></td>
</tr><tr>
<td colspan="2" align="center" class="bodytext"><input type="submit" name="Submit" value="Send" >
<input type="reset" value="Reset" name="reset"></td>
</tr></table>
<?php
};
?>
</body>
</html>
Code: Select all
[mail function]
; For Win32 only.
SMTP = 127.0.0.1(I use this IP address to send an email from my pc)
smtp_port = (this can be either 25 or 465 as both helped in sending an email with my gmail address)
; For Win32 only.
sendmail_from = sadak@worldonline.co.za
Code: Select all
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
#menu {
padding:0;
margin:0;
}
#menu ul {
list-style: none;
<!--margin: 0;
padding: 0;-->
border: none;
}
#menu li {
list-style-type:none;
}
#menu li a {
display: block;
text-decoration: none;
color: #fff;
border-left: 1px solid white;
border-right: 1px solid white;
width: 90px;
height: 25px;
border: 1px solid white;
}
<!--#menu li a:hover{
color: #fff;
}-->
</style>
</head>
<body bgcolor="#0000CD">
<div id="menu">
<ul>
<li><font size="2" color="white"><a href="http://localhost/Welcome_Page.html" target="mainframe"><center>Home Page</center></a></font></li>
<li><font size="2" color="white"><a href="http://localhost/Company_Profile.html" target="mainframe"><center>Profile</center></a></font></li>
<li><font size="2" color="white"><a href="http://localhost/map_information.html" target="mainframe"><center>Directions</center></a></font></li>
<li><font size="2" color="white"><a href="http://localhost/contactform.php" target="mainframe"><center>Contact us</center></a></font></li>
</ul>
</div>
</body>
</html>Thanks,
Naseem