Problems sending email using mail() function

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
beno747
Forum Newbie
Posts: 4
Joined: Thu Jun 16, 2005 12:17 am

Problems sending email using mail() function

Post by beno747 »

Hi Team,

I am having problems sending email from a website that I have created.

If I send the email to someone at the same domain the website has then it will not send.

If I send the email to anyone at a different domain then it works fine but for some weird reason not when I send to the same domain. I'll give you the code to have a squiz at.

Code: Select all

$message = "TEST";	
	$from = "Ben";
       $subject = "Subject";
	$to ="domain@domain.com"; // Lets just pretend that domain.com is the name of the website
	
	// Mail it
	
	$mail_success = mail($to, $subject, $message, $from);
	
	if ($mail_success == true) 
	{
		header("location:contactthanks.php");
		exit();
	} 
	
	else 
	{	
		header("location:contacterror.php?error=error+sending+email");
		exit();			
	}
If someone could help me out then I would be much appreciated.

d11wtq | Please use

Code: Select all

tags when posting PHP code[/color]
Syranide
Forum Contributor
Posts: 281
Joined: Fri May 20, 2005 3:16 pm
Location: Sweden

Post by Syranide »

if it is using a local SMTP it might be that it hasn't been configured for translating its name to local addresses, try sending the mail to the local IP address, should work if that's the problem.

otherwise it could be some spamfilter I guess.
Post Reply