Log in

View Full Version : help me with my script



wtl-php
06-28-2012, 03:55 PM
hi..:) how are you all ?

i programmed mail script and it's working , but i have some problem

here is the source


<?php

/**
* @author : wlt-php
* @copyright: 2012
*/

//mail(to ,title, msg, headers);


$EmaiL = $_POST['youremail'];
$title = $_POST['title'];
$impor = $_POST['impor'];
$tmsg = $_POST['textmsg'];
if(isset($_POST['do']) && $_POST['do'] == 'send'){

if(empty($EmaiL)){
echo "Please type E-mail";
}elseif(empty($tmsg)){
echo "Type Your Message ..!";
}else{
$to = "exampl@gmail.com";
$sub = $title;
$msg = $tmsg;
$headers ="MIMI-Version: 1.0 \r\n";
$headers .="From: $E-MaiL $title \r\n";
$headers .="Content-Type: text/html; charset=utf-8 \r\n";
$headers .="X-priority: 3 \r\n";
mail($to ,$title, $msg, $headers);
die("Message Sent");
}
}

?>
<form action="sendmail.php" method="POST" >
<table width="60" border="4" align="center">
<tr>
<td>E-mail</td>
<td><input type="text" name="youremail" size="40" /></td>
</tr>
<tr>
<td>Subject</td>
<td><input type="text" name="title" size="40" /></td>

</tr>
<tr>
<td>Message Box</td>
<td><textarea name="textmsg" rows="20" cols="30"></textarea></td>
</tr>
<tr>
<td></td>
<td><input type="submit" value="Send" /></td>
</tr>
</table>
<input type="hidden" name="do" value="send" />
</form>


the problem:

1- if i want to send E-mail first i have to modify the script and change the email to the one whom i want to send ($to = "exampl@gmail.com";)

how to make it sending e-mail without editing the code ? means i want to use it directly

and second thing .. i want to make it send many emails at once

can someone help me please and correct it

thank you

JShor
06-28-2012, 04:19 PM
You can write it so that the user separates the emails by a comma (e.g., "you@yourdomain.com, me@mydomain.com, joe@doe.com" would send to all three of those addresses).

Accept the string, split it using a comma as a delimiter and write a loop to iterate through each email.



<?php

/**
* @author : wlt-php
* @copyright: 2012
*/

//mail(to ,title, msg, headers);


$emails = explode(",", $_POST['youremail']);
$title = $_POST['title'];
$impor = $_POST['impor'];
$tmsg = $_POST['textmsg'];
if(isset($_POST['do']) && $_POST['do'] == 'send'){

if(count($emails) == 0){
echo "Please type E-mail";
}elseif(empty($tmsg)){
echo "Type Your Message ..!";
}else{
$sub = $title;
$msg = $tmsg;
$headers ="MIMI-Version: 1.0 \r\n";
$headers .="From: $E-MaiL $title \r\n";
$headers .="Content-Type: text/html; charset=utf-8 \r\n";
$headers .="X-priority: 3 \r\n";

foreach($emails as $e) {
$e = str_replace(" ", "", $e);
mail($e ,$title, $msg, $headers);
}
die("Message Sent");
}
}

?>
<form action="sendmail.php" method="POST" >
<table width="60" border="4" align="center">
<tr>
<td>E-mail</td>
<td><input type="text" name="youremail" size="40" /></td>
</tr>
<tr>
<td>Subject (separate by comma)</td>
<td><input type="text" name="title" size="40" /></td>

</tr>
<tr>
<td>Message Box</td>
<td><textarea name="textmsg" rows="20" cols="30"></textarea></td>
</tr>
<tr>
<td></td>
<td><input type="submit" value="Send" /></td>
</tr>
</table>
<input type="hidden" name="do" value="send" />
</form>

wtl-php
06-28-2012, 04:43 PM
very good .. thanks alot

but still second pro it's not solved

what i mean is .. there should be E-mail box for the mail list ..
suppose i have 1000 email of members want to send them message at once

and also number of time , like if i want to send same message twice at once

how to do that please

thank you again

Webiter
06-29-2012, 08:42 PM
This will help you build a Mail List Manager. Visitors can submit
their emails to your list and get an auto responder message in
return. The list/lists will enable you to send bulk messages from
time to time.

http://www.devshed.com/c/a/PHP/Creating-a-Mailing-List-Manager-with-PHP/

JShor
06-29-2012, 08:52 PM
what i mean is .. there should be E-mail box for the mail list ..
suppose i have 1000 email of members want to send them message at once


Be more specific. What do you mean by 'E-mail box'? The form field for email is the one where you would enter the 1000 email addresses.



and also number of time , like if i want to send same message twice at once


The modified script I made sends the email to all of the emails specified in the emails form field.