Jump to content

email


sstangle73

Recommended Posts

hey everyone making an email script and got a little stuck

 

the email doesnt send :P

 

<?php
if(isset($_POST['email'])){
$to = $_POST['emailto'];
$subject = $_POST['subject'];
$message = str_replace("\n.", "\n..", $_POST['emailbody']);
$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";

mail($to, $subject, $message, $headers);
echo "Success";
} else {
?>
<form action="<? echo $HTTP_SERVER_VARS['PHP_SELF']; ?>" method="post">
<table>
<tr><td>
<textarea name="emailto" rows="15" cols="50">email@domain.com; email@domain.com; email@domain.com</textarea>
</td></tr>
<tr><td>
<input type="text" name="subject" 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" value="From Name">
</td></tr>
<tr><td>
<input type="text" name="reply" maxlength="100" value="Reply To">
</td></tr>
<tr><td>
<input type="submit" name="email" value="Send!">
</td></tr>
</table>
</form>
<?php 
}
?>

Link to comment
Share on other sites

hehe you're trying to do multiple emails.

 

try:

 

<?php

$to = $_POST['emailto'];
// other variables

$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);
}

?>

Link to comment
Share on other sites

allright it sends. 3 problems:

 

1) the name and reply to address have a dot before it so if the inputed

Name: Joe Smith

it comes as

.Joe Smith

 

2) i dont think html works :(

. . . after some test i think i need to add slashes?

 

3) sometimes its going in my spam folder?

 

Link to comment
Share on other sites

allright i found where the dots were coming from

 

 

does anyone know why it gets flagged as spam? and also how do i send a html message with <img src"blah"> because "s mess up the script

 

 

<?php
error_reporting(E_ALL);
if(isset($_POST['email'])){
$to = $_POST['emailto'];
$subject = $_POST['subject'];
$amessage = nl2br($_POST['emailbody']);
$message = addslashes($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";
} else {
?>
<form action="<? echo $HTTP_SERVER_VARS['PHP_SELF']; ?>" method="post">
<table>
<tr><td>
<textarea name="emailto" rows="15" cols="50">email@domain.com; email@domain.com; email@domain.com</textarea>
</td></tr>
<tr><td>
<input type="text" name="subject" 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" value="From Name">
</td></tr>
<tr><td>
<input type="text" name="reply" maxlength="100" value="Reply To">
</td></tr>
<tr><td>
<input type="submit" name="email" value="Send!">
</td></tr>
</table>
</form>
<?php 
}
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.