7 Replies - 2578 Views - Last Post: 16 September 2008 - 04:37 PM Rate Topic: -----

#1 kummu4help   User is offline

  • D.I.C Head
  • member icon

Reputation: 4
  • View blog
  • Posts: 245
  • Joined: 05-August 08

mail() not working

Posted 13 September 2008 - 03:35 AM

Hi

i'm trying following code to send mail.
but it's not working i'm getting following error

Quote

Warning: mail() [function.mail]: SMTP server response: 550 5.7.1 Unable to relay for [email protected] in C:\Inetpub\wwwroot\test\try.php on line 37
There was traffic jam.. PHP Warning: mail() [function.mail]: SMTP server response: 550 5.7.1 Unable to relay for [email protected] in C:\Inetpub\wwwroot\test\try.php on line 37

i removed semecolon in front of
sendmail_from = [email protected]


in my php.ini file. do i need to make any changes in my php.ini to work with mail() function.
the following is my code
<?	
		date_default_timezone_set('Asia/Calcutta');	
	
	if (isset($_POST['Submit']))
	{
		$recepient=$_POST['email'];//[email protected]
		$Name = $_POST['name']; //senders name
		$sender = "[email protected]"; //recipient
		$mail_body = "The text for the mail..."; //mail body
		$subject = "Subject for reviever"; //subject
		$header = "From: ". $Name . " <" . $sender . ">\r\n"; //optional headerfields
		
		if (true==mail($recepient, $subject, $mail_body, $header))
		{
			print "Mail routed successfully...";
			
		}
		else
		{
			print "There was traffic jam..";
		}
	}
	
	else
	{
		print "data is not available for this page...";
	}	
?>



i am using valid email addresses.. both are active emails and i am using them
any help pls.....

This post has been edited by kummu4help: 13 September 2008 - 03:36 AM


Is This A Good Question/Topic? 0
  • +

Replies To: mail() not working

#2 CTphpnwb   User is offline

  • D.I.C Lover
  • member icon

Reputation: 3803
  • View blog
  • Posts: 13,814
  • Joined: 08-August 08

Re: mail() not working

Posted 13 September 2008 - 06:01 AM

It could be that your isp is blocking email that doesn't go through its smtp server.
Was This Post Helpful? 0
  • +
  • -

#3 papercup   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 15-June 07

Re: mail() not working

Posted 14 September 2008 - 02:08 AM

Is the SMTP server localhost? Do you have access to the config?

I was setting up a mail server the other week and I was getting that error alot during the setup while the configuration was wrong.
Was This Post Helpful? 0
  • +
  • -

#4 jonesa01   User is offline

  • D.I.C Head
  • member icon

Reputation: 25
  • View blog
  • Posts: 125
  • Joined: 18-February 07

Re: mail() not working

Posted 14 September 2008 - 10:42 AM

One thing i can see is this line:

if (true==mail($recepient, $subject, $mail_body, $header))



You should find that it will work like this:

if(mail($recepient,$subject,$mail_body,$header))



Adam
Was This Post Helpful? 0
  • +
  • -

#5 pemcconnell   User is offline

  • D.I.C Regular
  • member icon

Reputation: 54
  • View blog
  • Posts: 472
  • Joined: 05-August 08

Re: mail() not working

Posted 15 September 2008 - 03:32 AM

I noticed you asked about editting your php.ini file - which leads me to assume you are hosting these project files locally.

Setting up an smtp server to run locally is a tricky task - do you need this site to run from your local machine or is the end goal to host it on a web hosting package?

Your code is fine and will work on a server that has been set up to send emails (99.9% of web hosting packages) so I wouldn't worry about your form until it is on the live server.

If, on the other hand, you do want to be able to send emails to and from your own computer, i would recommend looking up a 'setting up an smtp server with PHP' tutorial.

Let me know how you get on, and fire any questions you have on this forum and we'll be glad to help.
Was This Post Helpful? 0
  • +
  • -

#6 kummu4help   User is offline

  • D.I.C Head
  • member icon

Reputation: 4
  • View blog
  • Posts: 245
  • Joined: 05-August 08

Re: mail() not working

Posted 15 September 2008 - 03:51 AM

thanks pemcconnell
i would like to run it from my local machine only
so how can i configure smtp on my local machine
i am using windowsxp,iis,php5.2.0
Was This Post Helpful? 0
  • +
  • -

#7 pemcconnell   User is offline

  • D.I.C Regular
  • member icon

Reputation: 54
  • View blog
  • Posts: 472
  • Joined: 05-August 08

Re: mail() not working

Posted 15 September 2008 - 06:51 AM

I would recommend googling 'setting up an SMTP server on apache' or whatever server environment you are running from - I know there are plenty of 'SMTP server on IIS' tutorials out there but you may not be running your PHP through IIS.

As far as I am aware, xampp (a popular PHP and apache environment) comes bundled with some SMTP support - might be worth reading up on that too.

To be honest I don't have enough expoerience setting up servers to give you an accurate tutorial on it, but there are plenty of tutorials already out there.

Good luck man, and let me know how you get on.
Was This Post Helpful? 0
  • +
  • -

#8 dreamincodehamza   User is offline

  • D.I.C Regular
  • member icon

Reputation: -12
  • View blog
  • Posts: 349
  • Joined: 12-September 08

Re: mail() not working

Posted 16 September 2008 - 04:37 PM

yeah you need to have one smtp server to send email using
php mail function .

and your isp must allow you to send email using smtp.
smtp port must be open on server and isp allow for that.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1