Page 1 of 1

How Email send by PHP

Posted: Fri Jan 13, 2012 6:44 am
by shizamalik
Help Required :(

me trying to understand this code function from last few days but still ifffffffffffffffffffffff. plz help me;

1: we use php code to send emails how the email send without smtp authentication.

2: second one is if my hosting plan allow me to send 50 emails per day and user email me through contact us page more than 50 emails than what happened (

suspended a/c kay elawa :p )

contact us page made by this code

can user can send me unlimited emails plz plz waiting for the positive response

Code: Select all

<?php

$site_name = "abc";
$admin_email = "info@domainname.com";
$url = "www.domainname.com";

?>

Code: Select all

<?php

if(!$_POST['submit']){

	echo "<table align=center border=0 cellspacing=0><tr><td>";
	echo "
	<h2>Contact Form</h2><br>
	Your comments are welcome.<br /><br>
	Please fill out this form and we will try to respond to you in as timely manner as possible.
	<br /><br /><br />
	<table class=table align=center cellspacing=0 cellpadding=5 border=0>
	<form action=contactus.php method=post>
	<tr><td bgcolor=#647A4E width=33%><b>Your Name:</b></td><td bgcolor=#647A4E><input type=text name=name></td></tr>
	<tr><td bgcolor=#647A4E><b>Email Address:</b></td><td bgcolor=#647A4E><input type=text name=email></td></tr>
	<tr><td bgcolor=#647A4E><b>Subject:</b></td><td bgcolor=#647A4E><input type=text name=subject size=30";
	
	if(isset($_GET['subject'])){
		$subject = $_GET['subject'];
		echo "value=\"$subject\"";
	}
	echo "></td></tr>
	<tr><td colspan=2 bgcolor=#647A4E>&nbsp;&nbsp;&nbsp;<b>Message:</b><br /><center><textarea name=body rows=10 cols=55>";
	if(isset($_GET['body'])){
		$body = $_GET['body'];
		echo "$body";
	}
	echo "</textarea></center></td></tr>
	<tr><td colspan=2 bgcolor=#647A4E><center><input type=submit class=submit name=submit value=\"Send Message\"></center></td></tr>
	</form>
	</table>";

}
else{

	if(!$_POST['subject'] || !$_POST['body']){
		echo "<span class=warning>You must fill out the Subject and the Message before this form is submitted.</span>";
	}
	else{
	
	$name = $_POST['name'];
	$email = $_POST["email"];
	$subject = $_POST['subject'];
	$body = $_POST['body'];
	
	$subj = "Contact from $name @ $site_name: $subject";
	$message = "$body\n\nSent by $name: $email";
	$email_info = "From: $email";
	
	mail($admin_email, stripslashes($subj), stripslashes($message), stripslashes($email_info));
	
	echo "<center>Thank you, Your message has been sent.</center>";
	}
}
echo "</td></tr></table>";

?>

Re: How Email send by PHP

Posted: Fri Jan 13, 2012 11:32 pm
by social_experiment
shizamalik wrote:can user can send me unlimited emails
If the hosting provider has set a limit on the amount of emails to be sent per day then you have to talk to them about it; mail() or using it in a specific way cannot control this;
http://tinyurl.com/cp2jh
Take a look at this url, and this section from the page
The Manual wrote: Note:

It is worth noting that the mail() function is not suitable for larger volumes of email in a loop. This function opens and closes an SMTP socket for each email, which is not very efficient.

For the sending of large amounts of email, see the » PEAR::Mail, and » PEAR::Mail_Queue packages.
I'm guessing you would need SMTP authentication for any email you send?