Page 1 of 1

mail() function giving strange behavior

Posted: Thu Feb 16, 2006 3:41 am
by lawrence_chtan
Hi to guru on the web

sorry for my inexperience in web development

I am trying to use the mail function. Apparently i dun think it help me to direct the mail over. instead. an error had been returned.

is anyone use the mail function before?

Warning: mail() [function.mail]: SMTP server response: 550 5.7.1 Unable to relay for lawrence.tan@yahoo.com in c:\Inetpub\wwwroot\04\processfeedback.php on line 14

my source code is

Code: Select all

<?php
  //create short variable names
  $name=$_POST['name'];
  $email=$_POST['email'];
  $feedback=$_POST['feedback'];

  $toaddress = 'lawrence.tan@yahoo.com';			//'feedback@example.com';
  $subject = 'Feedback from web site';
  $mailcontent = 'Customer name: '.$name."\n"
                 .'Customer email: '.$email."\n"
                 ."Customer comments: \n".$feedback."\n";
  $fromaddress = '127.0.0.1';	//'From: webserver@example.com';

  mail($toaddress, $subject, $mailcontent, $fromaddress);
?>
<html>
<head>
  <title>Bob's Auto Parts - Feedback Submitted</title>
</head>
<body>
<h1>Feedback submitted</h1>
<p>Your feedback has been sent.</p>


</body>
</html>
i m running IIS. with the virtual SMTP setting up.

Do i need to do anything at SMTP server? or i have to write the function for Mail()?

Posted: Sun Feb 19, 2006 12:21 pm
by MinDFreeZ
after having some trouble getting the mail() function to work with the IIS SMTP server i discovered the problem was simply that the SMTP server was set to 'localhost' in php.ini instead of the actual ip of the computer and hence IIS would filter the request out
source:
http://us2.php.net/manual/en/ref.mail.php#59836

found that by doing a google search.. try this real quick, because I'm really not sure...

http://www.google.com/search?hl=en&q=php+sendmail+iis

php sendmail iis

is what I searched for.

Posted: Mon Feb 20, 2006 7:11 pm
by lawrence_chtan
wuhoo everyone

found the solution.

1. I ask my exchange expert to test on my machine. find out that. the IIS SMTP service is not able to send out via the service. therefore i m changing my code to point to my school smtp server (i only able to send out via my school network).

2.

Code: Select all

$toaddress = 'lawrence.tan@yahoo.com';
  $subject = 'WLP - User Password Refresh';
  $mailcontent = 'User name: '.$name."\n"
                 .'User email: '.$email."\n"
                 ."User comments: \n".$feedback."\n";
  $fromaddress = '192.9.120.108';	

  mail($toaddress, $subject, $mailcontent, $fromaddress);
3.
go to PHP.ini modified the setting for the

SMTP = "192.2.120.108"
SMTP_PORT=25

sendmail_from = "192.9.120.108"

then Bingo.... the mail sent out.

so happy. now i can focus the coding for the database connection.