-1

I have a question about PHP email function, I hope you can help me with this. I have little to no experience in PHP.

Ive set up a web page, where users can submit following info via the HTML form: Name, Email, Phone, and couple Drop Down Selectors.

I have created an empty form.php and when clicked on submit, it gets connected to that php file. Thing is, I want the results to be mailed to my email address WIHOUT mysql database, as far as I know this is possible with PHP, but I couldnt find any tutorial for this.

Can you give me any pointers or guides please, how can I do it ?

Thanks in advance Cheers : ))

EDIT: I forgot to mention, with some PHP tutorials, I managed to send the mail to my email address, and managed to get the email subject correctly, but I couldnt get the results of email in the body of the email sent, body is always empty.

Can you please give me an example script, how I could get the results of this form in the body of message? Most tutorials show how to get $message in the body, but I dont really have any text to send via $message. I simply have couple text fields and couple drop down selectors.

4

2 回答 2

1

试试这个:

<?php
$to = "someone@example.com";
$subject = "Test mail";
$message = "Hello! This is a simple email message.";
$from = "someonelse@example.com";
$headers = "From:" . $from;

if(mail($to,$subject,$message,$headers)){
echo "Mail Sent.";}
else{
echo "Mail not sent";
}
?>

编辑: 1:soneonelse@example.com;和 'someonelse@example.com 只是两封不同的电子邮件,就像它提到了电子邮件的发件人和收件人一样,所以,请务必将我上面给出的电子邮件更改为您要发送的电子邮件。

2:如果你想风格,<div>那么做这样的事情:

 echo "<div style='color:white; background-color:red; font-size:14px; padding:20px; 
 border:1px solid black;'> Mail Sent</div>";
于 2013-05-17T00:13:30.007 回答
0

使用mail()功能:

mail($to, $subject, $message);

手册中的详细信息:http: //php.net/manual/en/function.mail.php

于 2013-05-16T23:25:00.183 回答