Jump to content

Archived

This topic is now archived and is closed to further replies.

Fearpig

mail() not working

Recommended Posts

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
[code][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[/code]

HTML Form
[code]<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>[/code]

...and here's the processing page
[code]<?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>";
}
?>[/code]

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

Share this post


Link to post
Share on other sites
Make sure that FER-MAIL.ferroli.local is the address to your smtp server.

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites

×

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.