The enigma of PHP, mail() and a hyphen

The enigma of PHP, mail() and a hyphen

Postby ceejay13 » Mon Jul 21, 2008 10:15 am

Hi Peeps,

I am using one of WebFusion's VPS servers and trying to get a home grown mail script working - it includes some traps and a Captcha script and works quite well on several other servers. BUT, in trying to migrate my sites to the single VPS, I am having trouble with the final line of the script - actually sending the mail.

This is the relevant part of the code:
Code: Select all
$subject = "Subject";
$message = "Remote IP: $ipadd, Referring Page: $refer\n Browser: $pagenti,\n\nSource: $tag\n\nName: $realname\nEmail: $email\n\nComments:\n$comments";
$headers = "From: $email\n";

//$sendto = "me@my".CHR(45)."address.co.uk";
//$sendto = "me@my\-address.co.uk";
//$sendto = "me@my-address.co.uk";
$sendto = "me@myaddress.co.uk";

mail($sendto, $subject, $message, $headers );
echo $sendto, $subject, $message, $headers;


The various '$sendto' are those I have tried (the CHR and the escaped hyphen from desparation :shock: ). If I use the last 'sendto' address with no hyphen, the mail is sent OK. However, put a hyphen in and the mail is not sent :? This is true of several domain names, not just one.

The echo is in there for me to check that the message is formed correctly (and it is). I have spent the last 3 days looking/searching for a solution and now seek advice/suggestions from here to get this running.

I like my script - I can change it quickly to cope with the various attacks that take place to SPAM/relay emails, and would like to continue using it as I understand it. But, if someone has a suggestion of a different script, then please let me know.

At the end of the day I don't like being beaten and would like to understand where the problem is - it could crop up again.

FWIW the SMTP is qmail running under Plesk 8.4.0 on Ubuntu 6.06

TIA
Colin
User avatar
ceejay13
Staff
 
Posts: 486
Joined: Sat Sep 24, 2005 10:38 am
Location: Basingstoke, Hampshire
ISP: Zen / BeUnlimited
Connection: 8Meg(5)/24Meg(5)
Allowance: 25G / Unlimited

Postby ceejay13 » Mon Jul 21, 2008 11:29 am

:oops: :oops: :oops: :oops: :oops: :oops: It was a 'PEBCAK' that has now been fixed.

You get the idea!!

I started reviewing logs (once I found out how to) and found that my emails were being sent correctly - it was just that they were going to the 'shadow' accounts I had already set up on the VPS server instead of the IP addresses that are in the 'world viewable' DNS servers.

I disabled the local websites (well in fact deleted them) and all is now OK. No wonder I couldn't find anything out there about fixing this problem!! Pretty obvious really.

I would now like to open a discussion on how problems are fixed by the original poster very quickly after requesting help and so looking like a complete fool.
Colin
User avatar
ceejay13
Staff
 
Posts: 486
Joined: Sat Sep 24, 2005 10:38 am
Location: Basingstoke, Hampshire
ISP: Zen / BeUnlimited
Connection: 8Meg(5)/24Meg(5)
Allowance: 25G / Unlimited

Postby Zig » Mon Jul 21, 2008 11:22 pm

Hi Colin,

I wish I had a penny for every Duh! that jumped up at smacked me in the face. I'd have my own island by now, :lol:

Glad you got it sorted though.

Cheers
Zig
 
Posts: 196
Joined: Sat Dec 03, 2005 5:24 pm
Location: St. Helens

Postby ceejay13 » Tue Jul 22, 2008 8:50 am

Must admit, it did have me going for a while.

Isn't it funny how me trying to migrate the sites to the VPS is causing me all sorts of niggles - which I am now afraid to metion in case of another 'PEBCAK'. I have mini web servers here and can play around with them to my hearts content with no problems, but this PLESK set up is proving to be a PITA. Probably me, but I will get there, and once I do it eases my load as I have websites at 3 different hosting companies.

The CAPTCHA on the email form is now being tempremental and it has saved me (and the other interested parties) from so much SPAM that it needs to be implemented before I can progress any further. Oh well, it's not asthough I am in a rush.
Colin
User avatar
ceejay13
Staff
 
Posts: 486
Joined: Sat Sep 24, 2005 10:38 am
Location: Basingstoke, Hampshire
ISP: Zen / BeUnlimited
Connection: 8Meg(5)/24Meg(5)
Allowance: 25G / Unlimited


Return to Linux

Who is online

Users browsing this forum: No registered users and 1 guest

cron