诱人的老师中文字幕在线观看
遊客:  註冊 | 登錄 | 幫助





標題: [求助] mail form problem
GT2     Rank: 3
青出藍
性別 男
UID 4090

精華 0
帖子 906
積分 244   詳情

閱讀權限 40
註冊 2006-8-5
來自
狀態 離線

 
 
 
 
發表於 2007-5-8 11:44 AM  資料  個人空間  短訊  加為好友 
mail form problem

X-Seek
此 X-Seek 主題價值 80 XS。 (天藍出手)
X-Seek 出題者 GT2 希望能在 2007-5-22 11:44 AM 前尋找到解決方案。
已於 2007-5-23 09:41 PM 由 GT2 選出最合適的解決方案及關閉 X-Seek 主題。

I want to write a form at html and the clients write that then just click the submit button.
The form will send to my account by email.
I try many method but those need to through outlook to send.
I don't want through outlook as somebody might not use.
Can anyone tell me some good methods.



[ 觀看解決方案 ]


最後編輯: mickeyGoUp : 2007-5-10 06:51 PM
頂部

lhy     Rank: 3
青出藍
性別 男
UID 14043

精華 0
帖子 121
積分 330   詳情

閱讀權限 40
註冊 2006-10-16
來自 Netherlands
狀態 離線

 
 
 
 
發表於 2007-5-8 07:04 PM  資料  個人空間  短訊  加為好友 
Try to make it in PHP. In php you can make use of the server's smtp server.

Step 1: Create your form

Here's a simple form I might use

<form action="process.php" method="post">
Name: <input type="text" name="name" size="20" maxlength="20" /><br />
Email: <input type="text" name="email" size="30" maxlength="30" /><br />
Subject: <input type="text" name="subject" size="30" maxlength="30" /><br />
Text:<textarea name="text" name="text" cols="50" rows="10"></textarea><br />
<input type="submit" name="submit" value="Send" />
</form>

Save this file as form.php. now for a little explanation.

You'll notice I used process.php as my form action. This is because the form data is going to be submitted to that file for actual mailing. I also wanted to limit how much data could be submitted. This is for security reasons. There is NEVER a reason why you shouldn't limit form data. Just so you know. ;)

Step 2: Processing the data

Now create a file called process.php.

First you want to get all the variables that were just sent to the page. Using the extract function, we can create identically named variables out of the $_POST array. In English this means that all the variables that have come to this page via the POST method (see the form above) will now be made into nice single-word variables.

@extract($_POST);

Now we want to make the data friendly for us.

$name = stripslashes($name);
$email = stripslashes($email);
$subject = stripslashes($subject);
$text = stripslashes($text);

Now we can do our mailing.

mail('youremail@domain.com',$subject,$text,"From: $name <$email>");

And finally redirect the user back to the form:

header("location:form.php");

So our code for process.php looks like this:

<?php
@extract($_POST);
$name = stripslashes($name);
$email = stripslashes($email);
$subject = stripslashes($subject);
$text = stripslashes($text);
mail('youremail@domain.com',$subject,$text,"From: $name <$email>");
header("location:form.php");
?>

There's plenty more you can do with mail().

Check out the mail function here.




X-Seek 解決方案 1/1   
頂部



GT2     Rank: 3
青出藍
性別 男
UID 4090

精華 0
帖子 906
積分 244   詳情

閱讀權限 40
註冊 2006-8-5
來自
狀態 離線

 
 
 
 
發表於 2007-5-8 10:42 PM  資料  個人空間  短訊  加為好友 
Hi lhy,
Thanks a lot.You are so kind.
Your reply is very detail and easy to understand!!!
I will try that.(ps.when I click "send",that will send mail as no need to through outlook,right??)
I also write a php page,but quite long.
So I think might be not so good to post here.
The page is no problem,I think,but the result was error......

頂部

lhy     Rank: 3
青出藍
性別 男
UID 14043

精華 0
帖子 121
積分 330   詳情

閱讀權限 40
註冊 2006-10-16
來自 Netherlands
狀態 離線

 
 
 
 
發表於 2007-5-9 12:17 AM  資料  個人空間  短訊  加為好友 
Hi GT2,

The script is I post is tested and working fine on lycos (Germany) server. It send mails to my hotmail account. If you have problems. Maybe post some code or error's you have got so we can fix it together.

Remember that many hosting provider have tighten the rules on they their server for sending mail remotely. Maybe you could check. Like my pay host require the header "From" to be my hosting domain name before they allow the mail go out.



最後編輯: lhy : 2007-5-9 12:21 AM
頂部

GT2     Rank: 3
青出藍
性別 男
UID 4090

精華 0
帖子 906
積分 244   詳情

閱讀權限 40
註冊 2006-8-5
來自
狀態 離線

 
 
 
 
發表於 2007-5-10 02:51 PM  資料  個人空間  短訊  加為好友 
HI lhy,
Thank you very much.
I will check my host server to confirm the point which you told me.
I cannot post the script to here now.I post the script when I back home.
If I use apache to test the script,what is the setting for the server???

頂部

lhy     Rank: 3
青出藍
性別 男
UID 14043

精華 0
帖子 121
積分 330   詳情

閱讀權限 40
註冊 2006-10-16
來自 Netherlands
狀態 離線

 
 
 
 
發表於 2007-5-11 09:41 AM  資料  個人空間  短訊  加為好友 

頂部

GT2     Rank: 3
青出藍
性別 男
UID 4090

精華 0
帖子 906
積分 244   詳情

閱讀權限 40
註冊 2006-8-5
來自
狀態 離線

 
 
 
 
發表於 2007-5-14 10:23 AM  資料  個人空間  短訊  加為好友 
Hi lhy,

I am sorry that the code is so long,the code is as below:

<?php
$recipientname = "abc";

$recipientemail = "abc@hotmail.com";

$subject = "Online-Form Response for $recipientname";

$autoresponse = "yes";

$autosubject = "Thank you for your mail!";

$automessage = "This is an auto response to let you know that we've successfully received your email sent through our email form. Thanks! We'll get back to you shortly.";

$thanks = "Thank you for contacting us.<br>We will get back to you as soon as possible.<br>";


?>

<style type="text/css"><!--
td,body,input,textarea {
        font-size:12px;
        font-family:Verdana,Arial,Helvetica,sans-serif;
        color:#000000}
--></style>
</head>
<body>

<table width="100%" height="100%"><tr>
<td valign="top"><font face="Verdana,Arial,Helvetica" size="2">

<?php
if($_POST['submitform']) {

$Name = $HTTP_POST_VARS['Name'];
$Email = $HTTP_POST_VARS['Email'];
$Comments = $HTTP_POST_VARS['Comments'];

$dcheck = explode(",",$require);
while(list($check) = each($dcheck)) {
if(!$$dcheck[$check]) {
$error .= "Missing $dcheck[$check]<br>";
}
}

if ((!ereg(".+\@.+\..+", $Email)) || (!ereg("^[a-zA-Z0-9_@.-]+$", $Email))){
$error .= "Invalid email address<br>";}


if($error) {
?>

<b>Error</b><br>
<?php echo $error; ?><br>
<a href="#" onClick="history.go(-1)">try again</a>


<?php
}
else
{

$browser = $HTTP_USER_AGENT;
$ip = $REMOTE_ADDR;


$message = "Online-Form Response for $recipientname:

Name: $Name
Email: $Email

Comments: $Comments

-----------------------------

Browser: $browser
User IP: $ip";

mail($recipientemail,"$subject","$message","From: $Name <$Email>");

if($autoresponse == "yes") {
$autosubject = stripslashes($autosubject);
$automessage = stripslashes($automessage);
mail($Email,"$autosubject","$automessage","From: $recipientname <$recipientemail>");
}

echo "$thanks";
}
}
else {
?>

<form name="contactform" action="<?php echo $PHP_SELF; ?>" method="post">
<input type="hidden" name="require" value="Name,Email,Comments">
<table><tr>
<td colspan="2" align="center"><b>Contact Me!</b><p></td>
</tr><tr>
<td valign="top" align="right">Name:</td>
<td valign="top"><input name="Name" size="25"></td>
</tr><tr>
<td valign="top" align="right">E-mail:</td>
<td valign="top"><input name="Email" size="25"></td>
</tr><tr>
<td valign="top" align="right">Comments:</td>
<td valign="top"><textarea name="Comments" rows="5" cols="35"></textarea></td>
</tr><tr>
<td colspan="2" align="center"><input type="submit" value="Submit" name="submitform">
<input type="reset" value="Reset" name="reset"></td>
</tr></table>
<br>

</form>
<?php } ?>
</font><p></td>
</tr><tr>
<td valign="bottom"><font face="Verdana" size="1">GT2Copyright@2007</font></td>
</tr></table>

The error message is missing.
and if I use the host server,$recipientemail will be the smtp server mail address??
Thanks a lot.

頂部

lhy     Rank: 3
青出藍
性別 男
UID 14043

精華 0
帖子 121
積分 330   詳情

閱讀權限 40
註冊 2006-10-16
來自 Netherlands
狀態 離線

 
 
 
 
發表於 2007-5-15 05:54 AM  資料  個人空間  短訊  加為好友 
I have put your code on my server and it works great. I pmed you the testing url.

頂部

GT2     Rank: 3
青出藍
性別 男
UID 4090

精華 0
帖子 906
積分 244   詳情

閱讀權限 40
註冊 2006-8-5
來自
狀態 離線

 
 
 
 
發表於 2007-5-15 08:19 AM  資料  個人空間  短訊  加為好友 
Hi lhy,

Thank you for your pm.
I tested one time.That is ok.The mail address is what??my code is abc@hotmail.com
I want to ask if I need to send a thank you letter,I need to use pop3 server??

Regards

頂部

lhy     Rank: 3
青出藍
性別 男
UID 14043

精華 0
帖子 121
積分 330   詳情

閱讀權限 40
註冊 2006-10-16
來自 Netherlands
狀態 離線

 
 
 
 
發表於 2007-5-15 03:40 PM  資料  個人空間  短訊  加為好友 
I just copy pasted your code into my server. Haven't change anyting. So That means your should get a mail to abc@hotmail.com and the submitter will get an auto reply.

Sending emails you need a smtp server not pop3. pop3 is for receiving emails. more info http://en.wikipedia.org/wiki/Post_Office_Protocol

頂部

快速美言
           


當前時區 GMT+8, 現在時間是 2024-5-7 06:44 PM

    Powered by Discuz!  © 2001-2007 Comsenz Inc.   
Processed in 0.019123 second(s), 9 queries

清除 Cookies - 聯繫我們 - LIPS Corner 新天藍 - Archiver