Jump to content


Photo

mail() not working


  • Please log in to reply
2 replies to this topic

#1 Fearpig

Fearpig
  • Members
  • PipPipPip
  • Advanced Member
  • 195 posts

Posted 20 October 2006 - 10:23 AM

Hi Guys,
I'm still having real problems sending a basic text e-mail through PHP. Could someone take a look at my code and settings and hopefully point me in the right direction?  :)

PHP.ini
[mail function]
; For Win32 only.
SMTP = FER-MAIL.ferroli.local; for Win32 only
smtp_port = 25
sendmail_from= Ferroli_IT@Ferroli.co.uk ; for Win32 only

HTML Form
<form name="LiteratureRequestForm" method="post" action="Process_Request_Form2.php">

<fieldset>
	<legend class='Body3'>CONTACT DETAILS</legend>
	<table width="400" border="0" cellspacing="0" cellpadding="4" class="Body2">
    <tr>
      <td width="157" align="right"><div align="right">*Name:</div></td>
      <td width="4">&nbsp;</td>
      <td width="215"><input name="Name" type="text" id="Name"></td>
</tr></table></fieldset>
	
	<table width="400" border="0" cellspacing="0" cellpadding="4" class="Body2">
    <tr>
      <td colspan="2" align="right" class="BodyText1">
        <div align="right">
          <input type="reset" name="Submit2" value="Clear Form">
        </div></td>
      <td><input type="submit" name="Submit" value="Submit"></td>
    </tr>
  </table>

</form>

...and here's the processing page
<?php

/* All form fields are automatically passed to the PHP script through the array $HTTP_POST_VARS. */
$email = 'someone@mydomain.co.uk';
$subject = 'literature request';
$message =  $HTTP_POST_VARS['Name'];

/* 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>";
}
?>

This  is the error message that I get popping up:

Warning: mail() [function.mail]: Failed to connect to mailserver at "FER-MAIL.ferroli.local" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in D:\Intranet v3\e-mail_test\Process_Request_Form2.php on line 25

Can't send email to someone@mydomain.co.uk


Any help would be REALLY appreciated as I've been stuck  ??? on this for days now!!
Cheers
Tom
"Whats wrong with the cat?" - Mrs Schrödinger

#2 Daniel0

Daniel0
  • Staff Alumni
  • Advanced Member
  • 11,956 posts

Posted 20 October 2006 - 10:26 AM

Make sure that FER-MAIL.ferroli.local is the address to your smtp server.

#3 Fearpig

Fearpig
  • Members
  • PipPipPip
  • Advanced Member
  • 195 posts

Posted 20 October 2006 - 11:24 AM

Hi Daniel0,
FER-MAIL is the name of my MS Exchange server, how do I confirm that this is the correct address for SMTP mail?
"Whats wrong with the cat?" - Mrs Schrödinger




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users