Jump to content

email


sstangle73

Recommended Posts

my script is sooooo slow anyone know a way to optimize it?

 

 

<?php
error_reporting(E_ALL);
if(isset($_POST['sendemail'])){
$pass = $_POST['password'];
if($pass == 'Shenentaha'){

$to = $_POST['emailto'];
$subject = stripslashes($_POST['subject']);
$amessage = nl2br($_POST['emailbody']);
$message = stripslashes($amessage);
$from = $_POST['from'];
$reply = $_POST['reply'];
$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: '  . $from . "\r\n";
$headers .= 'Reply-to: '  . $reply . "\r\n";
$ex = explode(",",$to);

if(count($ex) > 0){
foreach($ex AS $emails){
$email = trim($emails);
mail($email,$subject,$message,$headers);
}
}else {
mail($email,$subject,$message,$headers);
}

echo "Success<br><br><br><hr><br><br><br>New Email:";
} else {
echo "Wrong Password. Contact Steven";
}
}
?>
<form action="<? echo $HTTP_SERVER_VARS['PHP_SELF']; ?>" method="post">
<table>
<tr><td>
<textarea name="emailto" rows="15" cols="50">[email protected], [email protected], [email protected]</textarea>
</td></tr>
<tr><td>
<input type="text" name="subject" size="67" maxlength="100" value="subject">
</td></tr>
<tr><td>
<textarea name="emailbody" rows="15" cols="50">Message Here</textarea>
</td></tr>
<tr><td>
<input type="text" name="from" maxlength="100" size="67" value="From Name:  Name <[email protected]>">
</td></tr>
<tr><td>
<input type="text" name="reply" maxlength="100" size="67" value="Reply To: [email protected]">
</td></tr>
<tr><td>Enter Password:</td></tr><tr><td>
<input type="text" name="password" maxlength="50" size="67" value="Password">
</td></tr>

<tr><td>
<input type="submit" name="sendemail" value="Send!">
</td></tr>
</table>
</form>

Link to comment
https://forums.phpfreaks.com/topic/88310-email/
Share on other sites

 

 

add the comments tags around this code and telll me if the server is faster loool :D

comment tags like so

/* i am a comment balbla
$ex = explode(",",$to);

if(count($ex) > 0){
foreach($ex AS $emails){
$email = trim($emails);
mail($email,$subject,$message,$headers);
}
*/

 

 

 

The email might not work but it will defently b faster. If its faster then the problem is at foreach section coz you have not specified how many times it will loop and it goes n loops infinity number of times till a web browser such as internet explorer stops responding.

 

 

PS let me no if its faster then i help you re write that bit.

Link to comment
https://forums.phpfreaks.com/topic/88310-email/#findComment-452427
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.