Fail to send mail

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
rejoice
Forum Newbie
Posts: 2
Joined: Sun Aug 18, 2002 8:04 am
Location: Kuala Lumpur

Fail to send mail

Post by rejoice »

I'm having problem in sending the mail. The error appear like this:

Warning: Failed to Receive in C:\Program Files\Apache Group\Apache2\htdocs\firstweb\send_simpleform.php on line 19

Can anyone have idea what went wrong?

Code: Select all

<?

if (($sender_name == "") && ($sender_email == "") && ($message == "")) &#123;
	header("Location: http://localhost/simple_form.html");
	exit;
&#125;


$msg = "E-MAIL SENT FROM WWW SITE\n";
$msg .= "Sender's Name:    $sender_name\n";
$msg .= "Sender's E-Mail:  $sender_email\n";
$msg .= "Message:          $message\n\n";

$to = "xyz@x.y.my";
$subject = "Web Site Feedback";
$mailheaders = "From: My Web Site <> \n";
$mailheaders .= "Reply-To: $sender_email\n\n";

mail($to, $subject, $msg, $mailheaders);

?>

<HTML>
<HEAD>
<TITLE>Simple Feedback Form Sent</TITLE>
</HEAD>
<BODY>

<H1>The following e-mail has been sent:</H1>

<P><strong>Your Name:</strong><br>
<? echo "$sender_name"; ?>

<P><strong>Your E-Mail Address:</strong><br>
<? echo "$sender_email"; ?>

<P><strong>Message:</strong><br>
<? echo "$message"; ?>


</BODY>
</HTML>
My php.ini setting is:

Code: Select all

&#1111;mail function]
SMTP		= localhost		;for win32 only
sendmail_from	= abc@x.y.my	;for win32 only
Thanks to anyone who can help me... :-)
User avatar
Zeceer
Forum Contributor
Posts: 136
Joined: Fri Aug 02, 2002 5:10 am
Location: Norway

Post by Zeceer »

You have change your SMTP server in PHP.ini. I'm sure there are some servers where you live that you can use. Your ISP for an example. But you can try upload the script to a webserver that supports PHP and run it from there. That will do it.
rejoice
Forum Newbie
Posts: 2
Joined: Sun Aug 18, 2002 8:04 am
Location: Kuala Lumpur

Post by rejoice »

Do you mean that I can't test the script in localhost?... why can't?

Is there anything I can do to configure my PC in such a way that it can run locally?

Thanks.
User avatar
Zeceer
Forum Contributor
Posts: 136
Joined: Fri Aug 02, 2002 5:10 am
Location: Norway

Post by Zeceer »

Yes you can run you're mail functions locally by changing the SMTP settings in PHP.ini. If no SMTP is set then PHP got nothing to use to send the mail.

This is my settings. smtp.online.no is the SMTP server to my ISP provider. And I use that. Find the SMTP server of your ISP provider and write it where i have written mine.

[mail function]
; For Win32 only.
SMTP = smtp.online.no ; for Win32 only

; For Win32 only.
sendmail_from = Zeceer ; for Win32 only
Post Reply