Link to home
Start Free TrialLog in
Avatar of primalfear1
primalfear1

asked on

Problems using ISP SMTP server for PHP's Mail() function

I am trying to send an email to my email address using the mail() function, inside of a php form.

I am using a basic form... i pasted the code below.
This script and my server is on windows xp pro.

[PHP]
<html>
<head>

</head>
<body>
<form action="" method="post">
Name: <br>
<input type="text" name="name">
<br>
Email: <br>
<input type="text" name="email">
<br>
Subject: <br>
<input type="text" name="subject">
<br>
Text:<br>
<textarea name="message" cols="" rows=""></textarea><br>
<input type="submit" name="submit" value="Send">
<input type="reset" name="Reset" value="Reset">
</form>

Copy the html
</body>
</html>

<?php
if ($submit) { // if the form was sent do the following

if($name && $subject && $email && $message ) { // if all field are filled-in send email
mail("primalfear@comcast.net","$subject","$message","From: $name <$email>") or die("email error");
echo "Message Sent"; // if all went well, display message was sent
} else {
echo "All fields must be filled in!<BR>"; // if not all were filled in, display error message
}
} // end php submission code
?>

[PHP]


I changed my php.ini file to the following.

[mail function]
; For Win32 only.
SMTP = smtp.comcast.net
; For Win32 only.
sendmail_from = me@comcast.net
; For Unix only. You may supply arguments as well (default: "sendmail -t -i").
;sendmail_path = c:/apache2/mail/bin/sendmail.exe

I changed the me@comcast.net to my email address...


Does anyone know why it does not work?
Is there some smtp code to change the smtp server to something other than localhost?

I would appreciate any help.

Thanks

P.S

When i tried using a CGI script to send an email to the email specified in the form it worked.. so im pretty sure that my php.ini file is ok.
I even tried changing the smtp server to localhost

I also tried changing the recipitant email address from primalfear@comcast.net (or w/e it is) to admin@localhost.

When i did that, the little norton antivirus checked popped up (as is what happens when any email is being sent from my computer)  but, i need to send it to a real email address...  not admin@localhost.  

The goal of this is to create a validation script.. where they fill in their email and then the form sends an email to the email they specified.  But i already know how to do all that.. its figuring out my question above which is the important part.

I am running on a windows platform.

Thanks
ASKER CERTIFIED SOLUTION
Avatar of dkjariwala
dkjariwala

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of dkjariwala
dkjariwala

Oh, I see. You mentioned that you are trying to use ISP's SMTP server. It's a sure case now that your SMTP server requires you to authenticate before it can send mail to outside world.

Replace

$mail->Host     = "smtp1.site.com;smtp2.site.com"; // SMTP servers
$mail->SMTPAuth = true;     // turn on SMTP authentication
$mail->Username = "jswan";  // SMTP username
$mail->Password = "secret"; // SMTP password

above lines in previous code with

Your smtp server name, put your username/password which you use for corresponding POP account at your ISP. It should work.

JD