Jump to content

PHP form not submitting


craigeves

Recommended Posts

I am designing a site for a friend... but keep getting the following error when i submit the form.

 

warning: mail(): Failed to connect to a mail server at "mxhost-1.vi.net" port 25, verify your "SMTP" and "smtp_port" in php.ini or use ini_set() in D:\webhost\sendresults.php on line 39

 

This works fine on my website - can anyone tell me why it's not working properly now and how do i fix it?

 

Here's my code...

 

<?php
//--------------------------Set these paramaters--------------------------

// Subject of email sent to you.
$subject = 'Sample Request';

// Your email address. This is where the form information will be sent.
$emailadd = 'myemail@googlemail.com';

// Where to redirect after form is processed.
$url = 'thanks.html';

// Makes all fields required. If set to '1' no field can not be empty. If set to '0' any or all fields can be empty.
$req = '0';

// --------------------------Do not edit below this line--------------------------
$text = "Sample Request:\n\n";
$space = ' ';
$line = '
';
foreach ($_POST as $key => $value)
{
if ($req == '1')
{
if ($value == '')
{echo "$key is empty";die;}
}
$j = strlen($key);
if ($j >= 20)
{echo "Name of form element $key cannot be longer than 20 characters";die;}
$j = 20 - $j;
for ($i = 1; $i <= $j; $i++)
{$space .= ' ';}
$value = str_replace('\n', "$line", $value);
$conc = "{$key}:$space{$value}$line";
$text .= $conc;
$space = ' ';
}
mail($emailadd, $subject, $text, 'From: '.$emailadd.'');
echo '<META HTTP-EQUIV=Refresh CONTENT="0; URL='.$url.'">';
?>

 

Many thanks

Link to comment
Share on other sites

Is your friend's site being hosted on a different server?  I think you have to configure mail.

 

Yes he is on a different server. Different hosting company altogether. But they still run PHP. Does that make a difference then?

 

Sorry - quite new to PHP. I try to pick bits up as I go.

 

Thanks

Link to comment
Share on other sites

on my host i was only allowed to use a email that was registered on a site and i had to pay before the mail function could be used.

 

He already has a mail function in operation on the site, but its ASP - I am now switching over to PHP for the new site. Do you think this would make a difference them not allowing the mail function to be used?

 

Thanks

Link to comment
Share on other sites

Have you contacted them asking?

Also they may (again) only allow emails registered on the site to be used in the function.

 

You will need to contact them about there settings.

 

I have just emailed my friend to get him to get in contact with them.

 

I have tried the an email address at that domain but still no luck.

 

As soon as I get an answer i'll post a reply here to keep everyone updated in case it helps anyone else.

 

Thanks!

 

C

Link to comment
Share on other sites

I contacted the host and they told me....

 

If you are trying to send out emails from our server please use our relay service (sharedrelay.acitve24.com). thank you.

 

Ps. This is a relay server on port 25, it does not require authentication from our network but your traffic will monitored.

 

Does anyone know how I would add the ini_set() code to my script to change the server?

 

Many thanks

 

Craig

 

Link to comment
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.