PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old March 3rd, 2003, 02:00 PM
CyCo CyCo is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2003
Posts: 5 CyCo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
PHP Mail

I'm running apache on win32 with php installed. How can I send mail? What SMTP do I use? I get this warning when executing a mail script:

Warning: Failed to Receive in C:\indigoperl\apache\htdocs\FormToEmail.php on line 81

Reply With Quote
  #2  
Old March 3rd, 2003, 04:39 PM
FrankieShakes FrankieShakes is offline
Frank The Tank!
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: Jun 2002
Location: Toronto, Canada
Posts: 1,246 FrankieShakes User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 8
Send a message via ICQ to FrankieShakes Send a message via MSN to FrankieShakes
CyCo,

Can you paste the script you're using?

As for setting up outgoing mail in PHP, open your PHP.INI file, and find this line:

[mail function]
; For Win32 only.
SMTP = xx.xxx.xxx.xxx

And replace the x's with your ISP's outgoing SMTP server settings...

That's all there is to it.
__________________
____________________________________________
Developer Shed Weekly Writer | DevArticles Forum Moderator
Build Your Own KlipFolio Klip With PHP
FrankManno.com - Under Construction
Design Interactive Group - Under Construction

Reply With Quote
  #3  
Old March 3rd, 2003, 05:01 PM
CyCo CyCo is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2003
Posts: 5 CyCo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
BTW, even before the prior post, I had changed the SMTP = to my isp smtp conf. and tried several different free smtp server's addresses and still it would not mail...


<?php

/*

Thank you for choosing FormToEmail by ScriptsThatWork.com

Version 1.0 Created February 21st 2003

COPYRIGHT ScriptsThatWork.com 2003

You are not permitted to sell this script, but you can use it, copy it or distribute it providing that you do not delete this copyright notice, and you do not remove any reference to FormToEmail or ScriptsThatWork.com

DESCRIPTION

FormToEmail allows you to place a form on your website which your visitors can fill out and send to you. The contents of the form are sent to the email address which you specify below. The form allows your visitors to enter their name, email address and comments.

Your visitors (and nasty spambots!) cannot see your email address!

When the form is sent, your visitor will get a confirmation of this on the screen, and will be given a link to continue to your homepage, or other page if you specify it.

This is a PHP script. In order for it to run, you must have PHP on your webhosting account. If you are not sure about this, then ask your webhost about it.

SETUP INSTRUCTIONS

Step 1: Put the form on your webpage
Step 2: Enter your email address and continue link
Step 3: Upload the files to your webspace

Step 1:

To put the form on your webpage, copy the code below as it is, and paste it into your webpage:

<form action="FormToEmail.php" method="post">
<table border="0" bgcolor="#F0ECEC" cellspacing="5">
<tr><td><font face="arial"><b>Name</b></font></td><td><input type="text" size="30" name="name"></td></tr>
<tr><td><font face="arial"><b>Email address</b></font></td><td><input type="text" size="30" name="formemail"></td></tr>
<tr><td valign="top"><font face="arial"><b>Comments</b></font></td><td><textarea name="comments" rows="6" cols="30"></textarea></td></tr>
<tr><td>&nbsp;</td><td><input type="submit" value="Send"><font face="arial" size="1">&nbsp;&nbsp;FormToEmail by <a href="http://scriptsthatwork.com">ScriptsThatWork.com</a></font></td></tr>
</table>
</form>

Step 2:

Enter the email address below to send the form to:

*/

$email = "me@mymail.com";

/*

Enter the continue link to offer the user after the form is sent. If you do not change this, your visitor will be given a continue link to your homepage:

If you do change it, remove the "/" symbol below and replace with the name of the page to link to, eg: "mypage.htm" or "http://www.elsewhere.com/page.htm"

*/

$continue = "/";

/*

Step 3:

Save this file (FormToEmail.php) and upload it together with your webpage to your webspace. IMPORTANT - The file name is case sensitive! You must save it exactly as it is named above! Do not put this script in your cgi-bin directory (folder) it may not work from there.

THAT'S IT, FINISHED!

You do not need to make any changes below this line.

*/

// Send email

$name = stripslashes($name);
$comments = stripslashes($comments);

$subject = "FormToEmail Comments";
$message = "From: $name\nEmail address: $formemail\n\n$comments\n\n------------------------------------------------------------------\nThanks for using FormToEmail from http://www.ScriptsThatWork.com\n---...---------------";
$headers = "From: " . $formemail . "\n" . "Return-Path: " . $formemail . "\n" . "Reply-To: " . $formemail . "\n";

mail($email,$subject,$message,$headers);

?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>

<head>

<title>FormToEmail from ScriptsThatWork.com</title>

<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta http-equiv="Content-Language" content="en-uk">

</head>

<body bgcolor="#ffffff" text="#000000">
HI
<font face="arial">

<object><center>
<h1>Thank you <?php print "$name"; ?>!</h1>
<h2>Your form has been sent</h2>
<h3><a href="<?php print "$continue"; ?>">Click here to continue</a></h3>
<b>FormToEmail</b> by <a href="http://scriptsthatwork.com">ScriptsThatWork.com</a>
</center></object>

</font>

</body>
</html>

Reply With Quote
  #4  
Old March 4th, 2003, 11:42 AM
CyCo CyCo is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2003
Posts: 5 CyCo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Is this a bug...? Anyone else having this prob...?

Reply With Quote
  #5  
Old March 4th, 2003, 11:49 AM
FrankieShakes FrankieShakes is offline
Frank The Tank!
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: Jun 2002
Location: Toronto, Canada
Posts: 1,246 FrankieShakes User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 8
Send a message via ICQ to FrankieShakes Send a message via MSN to FrankieShakes
CyCo,

What version of PHP are you running? Also, do you have register_globals set to "ON" or "OFF" in your PHP.INI file?

Reply With Quote
  #6  
Old March 4th, 2003, 12:15 PM
CyCo CyCo is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2003
Posts: 5 CyCo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Hi,
I'm running PHP Version 4.2.3 Yes, register_globals = On, but I must tell you I tried Off as well. But, now that I think about it, I don't know if I restarted the server after that.(in Off mode) That "would" require a restart of the server to take effect, wouldn't it...?

Reply With Quote
  #7  
Old March 4th, 2003, 12:19 PM
FrankieShakes FrankieShakes is offline
Frank The Tank!
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: Jun 2002
Location: Toronto, Canada
Posts: 1,246 FrankieShakes User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 8
Send a message via ICQ to FrankieShakes Send a message via MSN to FrankieShakes
Yeah, if you change any settings in the INI file, you need to restart...

But you should be aware, that if you turn register_globals OFF, you will not be able to reference your form variables in the script using $formemail, etc...

You'll have to make use of the superglobal arrays... So you can create new variables in the script and assign them the value of the superglobals, or just use them directly when referring to the values in your script:

option 1:

PHP Code:
 $formEmail $_POST['formEmail']; 


Option 2:

PHP Code:
 $message "...\nEmail address: $_POST['formemail']..." 



Hope that helps...

Reply With Quote
  #8  
Old March 4th, 2003, 12:27 PM
CyCo CyCo is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2003
Posts: 5 CyCo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thumbs up

FrankieShakes

Thanx for your help. Much appreciated.

Reply With Quote
  #9  
Old March 9th, 2003, 02:08 PM
FrankieShakes FrankieShakes is offline
Frank The Tank!
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: Jun 2002
Location: Toronto, Canada
Posts: 1,246 FrankieShakes User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 8
Send a message via ICQ to FrankieShakes Send a message via MSN to FrankieShakes
Anytime... Glad I could help!

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingPHP Development > PHP Mail


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
Stay green...Green IT