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 protected]; [email protected]; [email protected]</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
https://forums.phpfreaks.com/topic/86951-email/
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
https://forums.phpfreaks.com/topic/86951-email/#findComment-444542
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
https://forums.phpfreaks.com/topic/86951-email/#findComment-444552
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 protected]; [email protected]; [email protected]</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
https://forums.phpfreaks.com/topic/86951-email/#findComment-444571
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.