sisom Posted January 20, 2011 Share Posted January 20, 2011 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. Quote Link to comment Share on other sites More sharing options...
sisom Posted January 22, 2011 Author Share Posted January 22, 2011 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.) Quote Link to comment Share on other sites More sharing options...
ActaNonVerba1 Posted January 22, 2011 Share Posted January 22, 2011 Is the dedicated server linux based? The Email syntax and abilities are slightly different on Linux than windows, and this may be causing your issue Quote Link to comment Share on other sites More sharing options...
PaulRyan Posted January 22, 2011 Share Posted January 22, 2011 Email must be sent to, or from, an existing email address hosted by Fasthosts. Try setting the $from variable to your e-mail address given or created on Fasthosts, this may be the issue. Regards, PaulRyan. Quote Link to comment Share on other sites More sharing options...
sisom Posted January 23, 2011 Author Share Posted January 23, 2011 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. Quote Link to comment Share on other sites More sharing options...
the182guy Posted January 23, 2011 Share Posted January 23, 2011 I'd change webhosts: Email must be sent to, or from, an existing email address hosted by Fasthosts. What if you needed a registration form for example, where users need to receive email from the server? Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted January 23, 2011 Share Posted January 23, 2011 I'm not sure how to read that. It does say 'to OR from', so I'd assume you'd be fine using your email address on the server as the From: header. You might want to contact their tech support and have them clarify that. Quote Link to comment Share on other sites More sharing options...
sisom Posted January 23, 2011 Author Share Posted January 23, 2011 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? Quote Link to comment Share on other sites More sharing options...
sisom Posted January 23, 2011 Author Share Posted January 23, 2011 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 Quote Link to comment Share on other sites More sharing options...
sisom Posted January 23, 2011 Author Share Posted January 23, 2011 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. Quote Link to comment Share on other sites More sharing options...
sisom Posted January 23, 2011 Author Share Posted January 23, 2011 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". Quote Link to comment Share on other sites More sharing options...
sisom Posted February 12, 2011 Author Share Posted February 12, 2011 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... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.