PHP- email not sending

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
shaik kaleem
Forum Newbie
Posts: 1
Joined: Thu Mar 29, 2012 11:28 pm

PHP- email not sending

Post by shaik kaleem »

Hello ,

I am very new to php function i never been used to it before... i want a web form on my website so that when ever the user entering the details and hit submit button, all the details filled should come to my email inbox.can any one help me to get the complete details, as i mentioned i am very new to php.... Thanks....
mc_guy
Forum Newbie
Posts: 5
Joined: Tue Mar 27, 2012 11:07 pm

Re: PHP- email not sending

Post by mc_guy »

This should work...

<?php

$SendFormTo = 'Type your email id';
$Emailsubject = 'Whatever sub line you want';

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

$body = "

Name - $Name
Email - $Email
Comments - $Comments

";

$headers = "From: $Email";
$success = mail($SendFormTo, $Emailsubject, $body, $headers);

header( "Location: http:yourcomp.com" );

?>
User avatar
social_experiment
DevNet Master
Posts: 2793
Joined: Sun Feb 15, 2009 11:08 am
Location: .za

Re: PHP- email not sending

Post by social_experiment »

You could also use search engines to find tutorials on the matter; you don't want a mail script that allows you form to be used as a platform from where spam is sent; field checking; possible captcha solutions are things you should look at
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
phphelpme
Forum Contributor
Posts: 261
Joined: Sun Nov 21, 2010 3:32 pm

Re: PHP- email not sending

Post by phphelpme »

Also, just as Social has mentioned, you really need to check that the submission is human or not because depending on your hosting provider you may have limits to how many messages get sent per minute. So if you get spammed you could end up with your account suspended on grounds of mass mailing.

This would happen because even though you are mailing everything to yourself, the systems that monitor this process do not take this into account. They just count the mail being sent via the mail() function.

Search Google for PHP FORMS
Search Google for reCaptcha etc such as http://www.google.com/recaptcha/captcha and ge to grips with it to make sure you are not subject to spam just like Social said.

Best wishes
Post Reply