Jump to content

Recommended Posts

Hi Guys,

Could someone have a look at the script I've been working on to send e-mail from a form...

I've been using the script from http://www.ibdhost.com/contact/ but I keep getting the following error:

 

Warning: mail() [function.mail]: Failed to connect to mailserver at "100.10.10.10" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in D:\Intranet v3\INTERNET\Sendeail.php on line 54

(I changed the IP Address before posting!)

 

Here is the code I am using:

 

Contact Form

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Email Form </title>
</head>
<body>

<form method="post" action="sendeail.php">

<!-- DO NOT change ANY of the php sections -->
<?php
$ipi = getenv("REMOTE_ADDR");
$httprefi = getenv ("HTTP_REFERER");
$httpagenti = getenv ("HTTP_USER_AGENT");
?>

<input type="hidden" name="ip" value="<?php echo $ipi ?>" />
<input type="hidden" name="httpref" value="<?php echo $httprefi ?>" />
<input type="hidden" name="httpagent" value="<?php echo $httpagenti ?>" />


Your Name: <br />
<input type="text" name="visitor" size="35" />
<br />
Your Email:<br />
<input type="text" name="visitormail" size="35" />
<br /> <br />
<br />
Attention:<br />
<select name="attn" size="1">
<option value=" Sales n Billing ">Sales n Billing </option> 
<option value=" General Support ">General Support </option> 
<option value=" Technical Support ">Technical Support </option> 
<option value=" Webmaster ">Webmaster </option> 
</select>
<br /><br />
Mail Message:
<br />
<textarea name="notes" rows="4" cols="40"></textarea>
<br />
<input type="submit" value="Send Mail" />
<br />
Free Code at: <a href="http://www.ibdhost.com/contact/">ibdhost.com/contact/</a>
</form>

</body>
</html>

 

Processing Page

<?php
$ip = $_POST['ip']; 
$httpref = $_POST['httpref']; 
$httpagent = $_POST['httpagent']; 
$visitor = $_POST['visitor']; 
$visitormail = $_POST['visitormail']; 
$notes = $_POST['notes'];
$attn = $_POST['attn'];
?> 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
<title>Sendemail Script</title>
</head>
<body>

<!-- Reminder: Add the link for the 'next page' (at the bottom) --> 
<!-- Reminder: Change 'YourEmail' to Your real email --> 

<?php
if(!$visitormail == "" && (!strstr($visitormail,"@") || !strstr($visitormail,"."))) 
{
echo "<h2>Use Back - Enter valid e-mail</h2>\n"; 
$badinput = "<h2>Feedback was NOT submitted</h2>\n";
echo $badinput;
}
if(empty($visitor) || empty($visitormail) || empty($notes )) {
echo "<h2>Use Back - fill in all fields</h2>\n";
}

$todayis = date("l, F j, Y, g:i a") ;

$attn = $attn ; 
$subject = $attn; 

$notes = stripcslashes($notes); 

$message = " $todayis [EST] \n
Attention: $attn \n
Message: $notes \n 
From: $visitor ($visitormail)\n
Additional Info : IP = $ip \n
Browser Info: $httpagent \n
Referral : $httpref \n
";

//$from = "From: $visitormail\r\n";
//The from address has been changed so the e-mail appear to come from a test address inside my domain
$from = "From: Internet_Form@MyDomain.co.uk";


mail("Test@MyDomain.co.uk", $subject, $message, $from);

?>

<p align="center">
Date: <?php echo $todayis ?> 
<br />
Thank You : <?php echo $visitor ?> ( <?php echo $visitormail ?> ) 
<br />

Attention: <?php echo $attn ?>
<br /> 
Message:<br /> 
<?php $notesout = str_replace("\r", "<br/>", $notes); 
echo $notesout; ?> 
<br />
<?php echo $ip ?> 

<br /><br />
<a href="contact.php"> Next Page </a> 
</p> 

</body>
</html>

 

I'd really appreciate it if someone could take a look at this and point out where I'm going wrong, or alternatively send me a link to a goood tutorial.

Thanks for your help.

Link to comment
https://forums.phpfreaks.com/topic/48601-solved-e-mail-form/
Share on other sites

Thanks MadTechie,

I've set up the php.ini file with the extract shown below:

 

[mail function]
; For Win32 only.
SMTP = 100.10.10.10; for Win32 only
smtp_port = 25
sendmail_from= Info@MyDomain.co.uk ; for Win32 only

 

...but I still get the same message. Am I ok using an IP address for the SMTP setting or should I use a web address such as mail.MyDomain.co.uk?

 

The Mail and Web servers are different computers and for the mail server I'm running Exchange 2003. Does anyone know where to check the settings that MadTechie mentioned? ...or could you recommend a Exchange forum!?

Link to comment
https://forums.phpfreaks.com/topic/48601-solved-e-mail-form/#findComment-237989
Share on other sites

Right then I've checked exchange and it still doesn't work!

 

Just incase anyone else is having this problem....

 

Open Exchange_Manager

Expand Administrative Groups

Expand your site

Expand Servers

Expand your Server

Expand Protocols

Expand SMTP

Right Click 'Default SMTP Virtual Server'

Select Properties

Select Access tab

 

Then check if you have Authentication rights, Connection Control rights and Relay Restrictions

 

 

Unfortunately this didn't help me! Having read lots on this issue now is it possible that Sendmail was never installed with PHP and how would I confirm that it is?

Link to comment
https://forums.phpfreaks.com/topic/48601-solved-e-mail-form/#findComment-238007
Share on other sites

OK on PHPinfo I've got the following entries under the PHP Core:

 

sendmail_from Me@Mydomain.co.uk Me@MyDomain.co.uk

sendmail_path no value no value

serialize_precision 100 100

short_open_tag On On

SMTP mailserver.mydomain mailserver.mydomain

smtp_port 25 25

 

Can anyone see any errors here?

Should I also have a Sendmail section or is it just the PHP Core enteries that I need?

 

Any help would be appreciated. ???

Link to comment
https://forums.phpfreaks.com/topic/48601-solved-e-mail-form/#findComment-238016
Share on other sites

;DRight then SORTED it!

 

The SMTP setting can be the IP or Host name

 

"SMTP string - Used under Windows only: host name or IP address of the SMTP server PHP should use for mail sent with the mail() function." - http://uk3.php.net/mail

 

Having the following section under PHP Core on a PHPinfo page means you do have sendmail installed:

 

sendmail_from Me@Mydomain.co.uk Me@MyDomain.co.uk

sendmail_path no value no value

serialize_precision 100 100

short_open_tag On On

SMTP 100.10.10.10 100.10.10.10

smtp_port 25 25

 

 

On exchange you should check the following

 

Open Exchange_Manager

Expand Administrative Groups

Expand your site

Expand Servers

Expand your Server

Expand Protocols

Expand SMTP

Right Click 'Default SMTP Virtual Server'

Select Properties

Select Access tab

Then check if you have Authentication rights, Connection Control rights and Relay Restrictions

 

 

...and last but not least - check the antivirus on the webserver allows programs other than outlook to send to SMTP servers!!!

...and now I feel stupid!

 

Thanks for the help MadTechie.

Link to comment
https://forums.phpfreaks.com/topic/48601-solved-e-mail-form/#findComment-238040
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.