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 22nd, 2005, 12:26 AM
Registered User
 
Join Date: Jun 2005
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default mail function

please help me out.....

i am a newbie to php and i have to use php for my major project in school. i am currently using php 5.0.4, iis 5.1, mysql

i had incooperated a helpdesk.php for my contact page and the codes goes like this:

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

$to="sunset_bay_85@yahoo.com";
$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 <sunset_bay_85@yahoo.com>\n";
$mailheaders.="Reply-To: $_GET[sender_email]\n";
$mailheaders.="Message: $_GET[message]\n";
mail($to,$subject,$msg,$mailheaders); // line 19
?>

<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 these:

<html><head>
<title>Help Desk</title>
</head><body>
<form action="helpdesk.php" method="GET" name="HelpDesk" id="HelpDesk">

<p><strong>Your Name:</strong> &nbsp;&nbsp;&nbsp;&nbsp;
  <input type="text" name="sender_name" size=30>
</p>
<p>&nbsp;</p>
<p><strong>Your Email Address:</strong>&nbsp;&nbsp;
  <input type="text" name="sender_email" size=30>
  <br>
</p>
<p>&nbsp;</p>
<p><strong>Message:</strong><br>
<textarea name="message" cols=60 rows=10 wrap=virtual><Enter your text here></textarea></p>

<p align="center"><input type="submit" name="submit" value="Send this form">

</form></body></html>


there is no error with the syntes but i have got this error saying:
"Warning: mail() [function mail]: SMTP server response: 5015.5.4 Invalid Address in c:/Inetpub/wwwroot/PBL/HelpDesk.php on line 19"

what could be the possible problem(s) that caused this error? i really need to complete this project.

anyone can help out???

desperate sunsetbay

 
Old June 22nd, 2005, 03:02 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 357
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to anshul
Default

Previous to $mailheaders="From: My Site <sunset_bay_85@yahoo.com>\n";

Write ini_set(sendmail_from, 'sunset_bay_85@yahoo.com');

Also add HTML type for e-mail in you want
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= continue_your_code_here

Tell us, if it doesn't go. http://www.mediasworks.com/scripts/
 
Old June 22nd, 2005, 09:25 AM
Registered User
 
Join Date: Jun 2005
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

thanx for helping me out but i have yet to test it out as the server is only available in school for the time begin. however, i have another thing i am still confused about. does that mean that by adding the codes, i do not have to edit the codes in the php.ini file which is listed below: ~?

[mail function]
; For Win32 only.
SMTP = smtp.aol.com
; For Win32 only.
sendmail_from = myemail@validadress.com

i am sorry that i am a little "noisy" but i still can't get the hang of php.

thanx a lot lot

desperate sunset

 
Old June 22nd, 2005, 09:53 PM
Registered User
 
Join Date: Jun 2005
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

now i've got another problem. it shows this error after i've include the lines above:

Notice: Undefined variable: sendmail_from in c:\Inetpub\wwwroot\PBL\helpdesk.php on line 24

when this line says this:

ini_set($sendmail_from, 'me@localhost.com');


how do i solve this problem. by the way, i have also installed a mail server on the same station as the iis server.
will there be any conflict between the 2??
 
Old June 24th, 2005, 03:33 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 357
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to anshul
Default

ini_set($sendmail_from, 'me@localhost.com');
Remove the extra $.

sendmail_from is a php.ini file variable and is available in all servers, reomte or local, Windows or Linux.

 
Old July 3rd, 2005, 08:59 PM
Registered User
 
Join Date: Jun 2005
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

but i'm currently running on the online server. does it meant thatby adding the above code would sent the mail to the server's localhost instead of my expected email address. and on top of that, my hosting server does not have mail function. does that meant that my website can't perform any php email function?

anyone please help out.

desperate sunset






Similar Threads
Thread Thread Starter Forum Replies Last Post
Send mail and attachments with PHP mail function Lofa Beginning PHP 1 June 2nd, 2008 03:24 PM
Mail function Rebel BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 39 November 14th, 2007 06:00 AM
mail function remo Beginning PHP 0 July 16th, 2007 05:45 AM
can't seem to get the mail() function to work Graham76 BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 0 October 5th, 2004 01:59 PM
mail () function Mark200408 BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 1 September 30th, 2004 07:59 AM





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