Wrox Programmer Forums
|
Beginning PHP Beginning-level PHP discussions. More advanced coders should post to the Pro PHP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning PHP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 30th, 2005, 12:15 AM
Registered User
 
Join Date: Jun 2005
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default email php

hi all,

i am doing a project on email php and after i've installed all the necessary programs on my station, i can't send email. however, it show the information i've input and these confirmation are done in the php codes.

when i checked my mail, there is no new mail sent by the php and shows no error message at all. what can i do to solve this problem.

my php codes looks like this:

<?PHP
if(($_GET['sender_name'] == "") ||
($_GET['sender_email'] == "") ||
($_GET['message'] == ""))
{
header("Location:contact.htm");
exit;
}

$to="[email protected]";
$subject="PBL Help Desk";

$msg="E-MAIL SENT FROM PBL Site\n";
$msg.="Sender's Name:\t$_GET[sender_name]\n";
$msg.="Sender's E-Mail:\t$_GET[sender_email]\n";
$msg.="Message:\t$_GET[message]\n";

$mailheaders="From: My Site <[email protected]>\n";
$mailheaders.="Reply-To: $_GET[sender_email]\n";
$mailheaders.="Message: $_GET[message]\n";
//$sendmail_from = mail($to,$subject,$msg,$mailheaders);
//ini_set($sendmail_from, '[email protected]');
mail($to,$subject,$msg,$mailheaders);

?>

<html><head>
<title>Temasek Polytechnic Online PBL Survival Kit</title>
</head><body>
<H1>The following email has been sent:</H1>
<p><strong>Your Name:</strong><br>
<? echo "$_GET[sender_name]"; ?>

<p><strong>Your Email Address:</strong><br>
<? echo "$_GET[sender_email]"; ?>

<p><strong>Message:</strong><br>
<? echo "$_GET[message]"; ?>

</body></html>

and my html code looks like this:
<form action="helpdesk.php" method="GET" name="HelpDesk" id="HelpDesk">
<p>&nbsp;</p>
<p>From: &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs p;&nbsp;
<input name="sender_name" type="text" id="sender_name" size="20">
<br>
<br>
Your Email Address: &nbsp;&nbsp;
<input name="sender_email" type="text" id="sender_email" size="30">
<br>
<br>
Your message</p>
<p>
<textarea name="message" cols="50" wrap=virtual rows="10" id="message"></textarea>
</p>
<p align="center">
<input type="submit" name="Submit" value="Submit">
<input name="Reset" type="submit" id="Reset" value="Reset">
</p>
</form>

please help me out....
desperate sunsetbay

 
Old July 7th, 2005, 10:55 PM
Registered User
 
Join Date: Jul 2005
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

It's supposed to be some setting problem in your smtp.

http://lifeasprogrammer.blogspot.com
 
Old July 8th, 2005, 06:43 AM
Authorized User
 
Join Date: Jul 2004
Posts: 79
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to rajuru Send a message via Yahoo to rajuru
Default

Dear,
Though I am not sure, I think this could for using exit() function.
After using header() function, exit() is not needed. Please remove this and try again.

and to send email use mail() function in the following way. it will help u to identify if your function works or not while you testing your application.

if(!mail($to,$subject,$msg,$mailheaders)){
echo "Mail Sent Successfully";
}else {
echo "Mail Can't Send";
}

Now, if you see success message & you don't get email then, there is not mistake in your script. Check the email address and check if your smtp is working.


Best Regard:
Md. Zakir Hossain (Raju)
www.rubd.net
www.xenexbd.com
Cheap Hosting, Domain, Reseller
www.forum.rubd.net
 
Old July 13th, 2005, 02:08 AM
Registered User
 
Join Date: Jun 2005
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hi,

after i've insert this codes, i still can send the mail and the error report this:

Warning: mail() function can't work properly. Cannot connect to SMTP "localhost", SMTP port "25"

When my SMTP = my IP address and my SMTP port = 25

What could be the possible problem???

I am already left with this problem to complete the project

Please help out.

Thanx

desperate sunset

 
Old July 13th, 2005, 02:10 AM
Registered User
 
Join Date: Jun 2005
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

by the way, i've already configured my php.ini file's SMTP settings and its proved working by my friend's forum using the same concept as my email function.

Thx

desperate sunsetbay

 
Old July 13th, 2005, 02:24 AM
Registered User
 
Join Date: Jul 2005
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Your problem occurs when you are running on local computer? If yes, what platform are you running? What server are you using?

Just trying to help. :) I've encountered this problem before. Hope that you are also in the same situation as I do.

http://lifeasprogrammer.blogspot.com
 
Old July 13th, 2005, 08:43 PM
Registered User
 
Join Date: Jun 2005
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

THX EVERYONE. i've successfully solved the problem and everything is working fine now. nice working with you guys and really thx alot for those who help and hope that i've helped others as well.

happy sunsetbay

 
Old July 16th, 2005, 01:57 PM
Registered User
 
Join Date: Feb 2005
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to SmoothAl Send a message via Yahoo to SmoothAl
Default

In regards to the e-mail issue...I have a form for people to request info from a site, where they enter their name, e-mail address, they choose a subject, enter comments, then submit that info. It sends an e-mail to the site owner, with their e-mail address in the "From" header, the subject in the "Subject" header, and the comments in the body of the e-mail, however, I can not get the "Name" they enter in the form to show up in the body of the e-mail, under the "comments".

Any ideas on what I am missing? Here's my code:

<?php
            $from = $_POST["Email"];
            $subject = $_POST["Subject"];
            $message = $_POST["Comments"] ;
            $headers = "From: " . $from . "\r\n";
            $mailsent = mail("[email protected]", $subject, $message, $headers);

            if ($mailsent) {
            echo "<H2>Thank you, " . $_POST['Name'];
            echo ", for your comments!</H2>";
            echo "Your message about " . $_POST['Subject'];
            echo ", is on its way to our staff for review.";
        } else {
            echo "There was an error. Please use the e-mail link provided on the Contact Us page.";
        }
            ?>


In the form that the info is being called from, the "Name" input box is labeled as "Name", subject = "Subject", email = "Email", comments = "Comments". So, I know that I need to insert a $_POST["Name"] somewhere, but I'm not sure how to get it in there without having it override and keep from showing the comments.

SmoothAl





Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP Email aftabn10 PHP How-To 2 January 30th, 2007 05:43 AM
how to send email in php? j4uk3n PHP How-To 4 November 25th, 2006 02:06 AM
Email In php 4 philuk86 Beginning PHP 19 July 14th, 2004 05:31 PM
trouble with Email and PHP Tachyon Beginning PHP 3 May 26th, 2004 03:58 AM
Q. How do I access my email with PHP? richard.york PHP FAQs 0 April 8th, 2004 09:51 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.