Jump to content

PHP mail form with Fasthosts server


sisom

Recommended Posts

Hi, I've been trying to use a simple contact form on a static website that I have hosted on a Fasthosts server, but Fasthosts have strict conditions on how the form should be set up, and I just can't get it to send mail.

 

This is Fasthosts' knowledge base about the conditions they require:

 

http://www.fasthosts.co.uk/knowledge-base/?article_id=70

 

I have been testing this simple file, mailtest.php, which is as follows:

 

<?php

mail('sales@mydomain.com','test message','this is a test sending mail from PHP','From: sales@mydomain.com' . "\r\n" .    'Reply-To: sales@mydomain' . "\r\n" .    'X-Mailer: PHP/', "-fsales@mydomain.com");

?>

 

I have a dedicated Fasthosts server, and I have tried running this file from the root of my website (which I shall call 'mydomain.com').

I also have an older Fasthosts hosting account, Windows Home, for around £5 a month, and if I use this PHP file on that site, (obviously changing the 'from' address to the e-mail address for that site) then it works fine!

 

Is there anything obvious that I have done wrong in the PHP above?

I have gone into /etc/mail/trusted-users and added

www-data

as the user, but that didn't help either.

 

Please let me know if there is any other information I can give that might help, I've spent over five hours trying to work this out but so far no luck, I am very grateful for any help you can offer.

 

Link to comment
Share on other sites

Hi, I've just done another test with the following simple php file:

 

 

<?php

$from = "thefromemailaddress@domain";

mail("recipient", "Test mail from PHP mail","This is a test PHP Email","From: $from", "-f$from" );

print "Mail sent";

?>

 

on both the dedicated server (which isn't sending mails) and the Fasthosts 'Windows Home' package that I have another website on (on which all PHP mailers seem to work fine).

 

On the dedicated server, if I leave the "recipient" part exactly as it is (because I forgot to edit that part!) it acts as if it has sent the mail, and the screen says "Mail sent".

On the 'Windows Home' website, it brings up the following error message as soon as I've gone to the php file in my browser:

 

Warning: mail() [function.mail]: SMTP server response: 450 <recipient>: Recipient address rejected: User unknown in local recipient table in E:\domains\t\mywebsite.com\user\htdocs\finaltest.php on line 3

Mail sent

 

 

So it's as if the dedicated server isn't even bothering to send the mail to the SMTP server at all! Do you have any ideas why this might be?

 

(When I insert an e-mail address, instead of 'recipient', it works fine on the 'Windows Home' website, by the way.)

Link to comment
Share on other sites

Thanks for your help guys, I think it's something worse than that, I tried changing the test php file to this:

 

<?php

ini_set('display_errors',1);

error_reporting(E_ALL|E_STRICT);

$from = "mymail@mysite.com";

mail("mymail@myothersite.com", "Test mail from PHP mail","This is a test PHP Email","From: $from", "-f$from" );

print "Mail sent";

?>

 

(I think I must have error reporting turned off in the php.ini (or wherever it is, I can't remember now as my brain's turned to jelly after trying to fix this all day!) so I turned it back on for this php file)

and it still just says

"Mail sent" and doesn't appear to have found any errors.

 

The from e-mail address is definitely the Fasthosts one, the file is hosted on www.mysite.com, so it should work.

 

 

Link to comment
Share on other sites

Hi guys, it's to OR from, it's to stop spammers from using Fasthosts servers, I suppose.

 

The interesting thing is that I was able to get the following PHP file to work fine on my 'Windows Home' package:

 

<?php

$to      = 'mymail@nonfasthostssite.com';

$subject = 'Test from mailer2.php';

$message = 'The quick brown fox jumped over the lazy dog.';

$headers = 'From: sales@myfasthostsite.com' . "\r\n" .

    'Reply-To: sales@myfasthostsite.com' . "\r\n" .

    'X-Mailer: PHP/' . phpversion();

 

mail($to, $subject, $message, $headers);

?>

 

and it sent the mail to

mymail@nonfasthostssite.com

 

with no problems at all! So it's very odd. I suppose the Windows Home package isn't as susceptible as being used by spammers, as they don't have control over the server at all?

Link to comment
Share on other sites

I should have said in my previous post, that I didn't have to include the

-fsales@mysite.com

 

parameter, yet it still sent the e-mails.

 

I've had a looked at /var/log/mailllog.1, and the last part is like this (well, it's all like this but there's no point in pasting in 100 lines that look the same!):

 

Jan 23 00:36:06 server44-200-211-235 postfix/postdrop[28549]: warning: unable to look up public/pickup: No such file or directory

Jan 23 00:48:38 server44-200-211-235 postfix/postdrop[28583]: warning: unable to look up public/pickup: No such file or directory

Jan 23 02:00:08 server44-200-211-235 postfix/postdrop[28765]: warning: unable to look up public/pickup: No such file or directory

Jan 23 04:02:20 server44-200-211-235 postfix/postdrop[29498]: warning: unable to look up public/pickup: No such file or directory

 

 

I believe this must be the cause of the problem. I read somewhere on another forum that it's possible there are two mail programs running, can I search for them to see if that is the case?

 

 

Here is what the other forum says:

 

http://ubuntuforums.org/showthread.php?t=666018

Link to comment
Share on other sites

I found 'postfix' in /etc/postfix

and then tried

postfix reload

(which I read about on the other forum), it said "fatal: the Postfix mail system is not running".

I then tried

postfix start

and it said "warning: not owned by postfix: /var/spool/postfix/public/pickup

postfix/postfix-script: starting the Postfix mail system"

 

How do I change the /var/spool/postfix/public/pickup to be owned by postfix?

Just use

chown postfix /var/spool/postfix/public/pickup

?

 

Okay, I tried that, then I tried

postfix reload

and it said postfix was not running, then I tried

postfix start

and this time it said "postfix/postfix-script: starting the Postfix mail system"

without any warning about /pickup not being owned by it.

Link to comment
Share on other sites

I wanted to test whether Postfix was running properly, so I tried to enter some of this code:

 

telnet servername 25

ehlo testmail.org

mail from:<test@testmail.org>

rcpt to:<cactus@virtualdomain.tld>

data

This is a test email.

 

.

quit

 

from this page:

https://wiki.archlinux.org/index.php/Postfix#Step_1:_Start_postfix

 

but I can't get the first line to work. What should I put in for 'servername'?

I tried

telnet server44-200-211-235 25

but it said "Cannot connect to 44-200-211-235".

Link to comment
Share on other sites

  • 3 weeks later...

Just to keep you up to date, I have just rebooted the server using:

/sbin/shutdown -r now

 

and while reading the various processes being shut down,  I noticed that it said:

Shutting down Postfix - FAILED

 

Fasthosts' support are looking into the original problem, but haven't got back after three or four days...

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.