?
Solved

SUBMIT A HTML FORM TO MY WEB EMAIL ADDRESS USING PHP

Posted on 2007-08-05
22
Medium Priority
?
245 Views
Last Modified: 2007-08-05
HELLO
I have a small website and i wnat users to be able to contact me using the form below. Name/Business/Email & Tel.

I want details of the sent form to go to my webmail address. Is it possible to do this? Or could you please advise me of the best method.

Thanks EE

<form method="post" action="mailto:info@onevisionwebdesign.co.uk">
Name: <br />
<input type="text" name="name" size="35" />
<br />
Business Name:<br />
<input type="text" name="businessname" size="35" />
<br />
Email:<br />
<input type="text" name="email" size="35" />
<br />
Tel:<br />
<input type="text" name="tel" size="35" />
<br />
<input type="submit" value="Send Mail" />
<br /></form>
0
Comment
Question by:kevinb4940
  • 12
  • 10
22 Comments
 
LVL 28

Expert Comment

by:gamebits
ID: 19634162
I think the mailto action of a form is not supported anymore, would be easier to use a php script to do that.
0
 
LVL 28

Accepted Solution

by:
gamebits earned 2000 total points
ID: 19634188
Your form

<form method="post" action="sendmailto.php">
Name: <br />
<input type="text" name="name" size="35" />
<br />
Business Name:<br />
<input type="text" name="businessname" size="35" />
<br />
Email:<br />
<input type="text" name="email" size="35" />
<br />
Tel:<br />
<input type="text" name="tel" size="35" />
<br />
<input type="submit" value="Send Mail" />
<br /></form>

the script save as sendmailto.php

<?
$name = $_POST['name'];
$businessname = $_POST['businessname'];
$email = $_POST['email'];
$tel = $_POST['tel'];

$subject = Put here the subject you want to see
$message = "New contact \n
Name: $name
Business: $businessname
Email: $email
Tel: $tel

$from = "From: $email\r\n";
mail("EMAIL ADDRESS TO SEND TO", $subject, $message, $from);
mail("$courriel", $subject, $messageclient, $from);

echo "<h1><i>Thank you</i></h1>";
?
0
 

Author Comment

by:kevinb4940
ID: 19634458
Hi gamebits I was out there for a while .
what extension do I save this file, is it .php
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:kevinb4940
ID: 19634467
Sorry. youve told me  that already
0
 

Author Comment

by:kevinb4940
ID: 19634509
Hi

im getting an error on my local server when I test the code

Parse error: syntax error, unexpected T_STRING in C:\Inetpub\wwwroot\php\sendmailto.php on line 7

Thanks
0
 
LVL 28

Assisted Solution

by:gamebits
gamebits earned 2000 total points
ID: 19634541
My bad

replace

$subject = Put here the subject you want to see

by

$subject = "Put here the subject you want to see";
0
 

Author Comment

by:kevinb4940
ID: 19634566
I tried that still getting same error.

Should there be semicolons after  all the variables below?

$subject = "Put here the subject you want to see";
$message = "New contact \n
Name: $name
Business: $businessname
Email: $email
Tel: $tel


Thanks
0
 
LVL 28

Expert Comment

by:gamebits
ID: 19634575
No because they are part of the $message variable, give me a minute to double check what is going on.
0
 

Author Comment

by:kevinb4940
ID: 19634586
Got that fixed, now getting error

Parse error: syntax error, unexpected T_STRING in C:\Inetpub\wwwroot\php\sendmailto.php on line 14
line 14 is $from = "From: $email\r\n";
                           
0
 
LVL 28

Assisted Solution

by:gamebits
gamebits earned 2000 total points
ID: 19634602
replace

Tel: $tel

by

Tel: $tel";

revised script

<?
$name = $_POST['name'];
$businessname = $_POST['businessname'];
$email = $_POST['email'];
$tel = $_POST['tel'];

$subject = "Put here the subject you want to see";
$message = "New contact \n
Name: $name
Business: $businessname
Email: $email
Tel: $tel";

$from = "From: $email\r\n";
mail("YOUR EMAIL ADDRESS", $subject, $message, $from);
mail("$courriel", $subject, $messageclient, $from);

echo "<h1><i>Thank you</i></h1>";
?>
0
 

Author Comment

by:kevinb4940
ID: 19634619
Thanks
Im getting somewhere now. Getting 2 warnings now

Warning: mail() [function.mail]: SMTP server response: 550 5.7.1 Unable to relay for info@onevisionwebdesign.co.uk in C:\Inetpub\wwwroot\php\sendmailto.php on line 15

Warning: mail() [function.mail]: SMTP server response: 503 5.5.2 Need Rcpt command. in C:\Inetpub\wwwroot\php\sendmailto.php on line 16

Thank you
0
 

Author Comment

by:kevinb4940
ID: 19634624
The thankyou message at the bottom is coming up on sendmailto.php

<?
$name = $_POST['name'];
$businessname = $_POST['businessname'];
$email = $_POST['email'];
$tel = $_POST['tel'];

$subject = "Put here the subject you want to see";
$message = "New contact \n
Name: $name
Business: $businessname
Email: $email
Tel: $tel";

$from = "From: $email\r\n";
mail("info@onevisionwebdesign.co.uk", $subject, $message, $from);
mail("$courriel", $subject, $messageclient, $from);

echo "<h1><i>Thank you</i></h1>";
?>
0
 
LVL 28

Expert Comment

by:gamebits
ID: 19634633
I just tried your script with my server, so you should have received an email from me.
0
 
LVL 28

Expert Comment

by:gamebits
ID: 19634642
I don't know if you have access to the server but you may want to look a the PHP mail function

http://ca.php.net/mail
0
 

Author Comment

by:kevinb4940
ID: 19634647
This is the message when I load it onto the my host server

Warning: mail() [function.mail]: SMTP server response: 503 Must have sender and recipient first. in C:\inetpub\vhosts\onevisionwebdesign.co.uk\httpdocs\sendmailto.php on line 16

Thank you

0
 

Author Comment

by:kevinb4940
ID: 19634674
The emails are gettijng through I got yours ok
Mine are getting to my mailbox have an invalid error message on them.

When I send from my webapge I get
Warning: mail() [function.mail]: SMTP server response: 503 Must have sender and recipient first. in C:\inetpub\vhosts\onevisionwebdesign.co.uk\httpdocs\sendmailto.php on line 16

Thank you
0
 
LVL 28

Assisted Solution

by:gamebits
gamebits earned 2000 total points
ID: 19634694
Do me a favor, remove this line

mail("$courriel", $subject, $messageclient, $from);

(should be line 16)
0
 

Author Comment

by:kevinb4940
ID: 19634728
that worked gamebits thanks. Thanks for your incredible patience.
You should programme on one of those guru sites and get well paid for it.

One more small thing
Im missing the date on my emails

Thanks Awarding points now
0
 
LVL 28

Expert Comment

by:gamebits
ID: 19634758
"Im missing the date on my emails" not sure what you mean, where is it missing?
0
 

Author Comment

by:kevinb4940
ID: 19634792
By the way the site I have up is only for testing purposes. (I am not a profesional webdesigner by any means) I dont have it ranked or anything.

Im still a student but I found it really good experience getting myself into real world situations concerning webdesign . i only startedlearning  php about a week ago. They taught us asp and sql at college and some asp.net. php has loads of functions

thanks
0
 

Author Comment

by:kevinb4940
ID: 19634810
Its missing in my inbox

      DATE          FROM                         SUBJECT
  1  08/03/07  Scrub The Web  Submit URL: Confirmation Required 4 KB
  2  17:50:44  gamebits2@hotmail.com  Put here the subject you want to see 1 KB
  3  Unknown Date  kevinblakely@hotmail.com  Put here the subject you want to see 460
     
When I open the email it shows the date though
 

0
 
LVL 28

Expert Comment

by:gamebits
ID: 19634826
mmm! I'll have to investigate, in my inbox I have the date no problem.
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s a season to be thankful, and we’re thankful for users like you who engage on site, solve technology problems, and network with others in the industry. What tech are we most thankful for? Keep reading.
MS Outlook undoubtedly is the most widely used email client.Its user-friendliness, cost effectiveness, and availability with Microsoft Office Suite make it the most popular email application.  Its compatibility with Microsoft applications like Exch…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Suggested Courses
Course of the Month14 days, 8 hours left to enroll

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question