Jump to content

Recommended Posts

guys, i got two php mailers, one of them is working like charm, the other DOES not work, although it works on a different server... here are the two sources:



<?


If ($action=="mysql"){

#Grab email addresses from MySQL

include "./mysql.info.php";

if (!$sqlhost || !$sqllogin || !$sqlpass || !$sqldb || !$sqlquery){

print "Please configure mysql.info.php with your MySQL information. All settings in this config file are required.";

exit;

}

$db = mysql_connect($sqlhost, $sqllogin, $sqlpass) or die("Connection to MySQL Failed.");

mysql_select_db($sqldb, $db) or die("Could not select database $sqldb");

$result = mysql_query($sqlquery) or die("Query Failed: $sqlquery");

$numrows = mysql_num_rows($result);



for($x=0; $x<$numrows; $x++){

$result_row = mysql_fetch_row($result);

$oneemail = $result_row[0];

$emaillist .= $oneemail."\n";

}

}



if ($action=="send"){

$message = urlencode($message);

$message = ereg_replace("%5C%22", "%22", $message);

$message = urldecode($message);
$message = stripslashes($message);
$subject = stripslashes($subject);

}



?>

<form name="form1" method="post" action="" enctype="multipart/form-data">

<br>

<table width="100%" border="0">

<tr>

<td width="10%">

<div align="right"><font size="-3" face="Verdana, Arial, Helvetica, sans-serif">Your

Email:</font></div>

</td>

<td width="18%"><font size="-3" face="Verdana, Arial, Helvetica, sans-serif">

<input type="text" name="from" value="email" size="30">

</font></td>

<td width="31%">

<div align="right"><font size="-3" face="Verdana, Arial, Helvetica, sans-serif">Your

Name:</font></div>

</td>

<td width="41%"><font size="-3" face="Verdana, Arial, Helvetica, sans-serif">

<input type="text" name="realname" value="name" size="30">

</font></td>

</tr>

<tr>

<td width="10%">

<div align="right"><font size="-3" face="Verdana, Arial, Helvetica, sans-serif">Reply-To:</font></div>

</td>

<td width="18%"><font size="-3" face="Verdana, Arial, Helvetica, sans-serif">

<input type="text" name="replyto" value="" size="30">

</font></td>

<td width="31%">

<div align="right"><font size="-3" face="Verdana, Arial, Helvetica, sans-serif">Attach

File:</font></div>

</td>

<td width="41%"><font size="-3" face="Verdana, Arial, Helvetica, sans-serif">

<input type="file" name="file" size="30">

</font></td>

</tr>

<tr>

<td width="10%">

<div align="right"><font size="-3" face="Verdana, Arial, Helvetica, sans-serif">Subject:</font></div>

</td>

<td colspan="3"><font size="-3" face="Verdana, Arial, Helvetica, sans-serif">

<input type="text" name="subject" value="subject" size="90">

</font></td>

</tr>

<tr valign="top">

<td colspan="3"><font size="-3" face="Verdana, Arial, Helvetica, sans-serif">

<textarea name="message" cols="60" rows="10">

</textarea>

<br>

<input type="radio" name="contenttype" value="plain">

Plain

<input type="radio" name="contenttype" value="html" checked>

HTML

<input type="hidden" name="action" value="send">

<input type="submit" value="Send eMails">

</font></td>

<td width="41%"><font size="-3" face="Verdana, Arial, Helvetica, sans-serif">

<textarea name="emaillist" cols="30" rows="10"></textarea>

</font></td>

</tr>

</table>

</form>



<?

if ($action=="send"){



if (!$from && !$subject && !$message && !$emaillist){

print "Please complete all fields before sending your message.";

exit;

}



$allemails = split("\n", $emaillist);

$numemails = count($allemails);



#Open the file attachment if any, and base64_encode it for email transport

If ($file_name){

@copy($file, "./$file_name") or die("The file you are trying to upload couldn't be copied to the server");

$content = fread(fopen($file,"r"),filesize($file));

$content = chunk_split(base64_encode($content));

$uid = strtoupper(md5(uniqid(time())));

$name = basename($file);

}



for($x=0; $x<$numemails; $x++){

$to = $allemails[$x];

if ($to){

$to = ereg_replace(" ", "", $to);

$message = ereg_replace("&email&", $to, $message);

$subject = ereg_replace("&email&", $to, $subject);

print "$to";

flush();

$header = "From: $realname <$from>\r\nReply-To: $replyto\r\n";

$header .= "MIME-Version: 1.0\r\n";

If ($file_name) $header .= "Content-Type: multipart/mixed; boundary=$uid\r\n";

If ($file_name) $header .= "--$uid\r\n";

$header .= "Content-Type: text/$contenttype\r\n";

$header .= "Content-Transfer-Encoding: 8bit\r\n\r\n";

$header .= "$message\r\n";

If ($file_name) $header .= "--$uid\r\n";

If ($file_name) $header .= "Content-Type: $file_type; name=\"$file_name\"\r\n";

If ($file_name) $header .= "Content-Transfer-Encoding: base64\r\n";

If ($file_name) $header .= "Content-Disposition: attachment; filename=\"$file_name\"\r\n\r\n";

If ($file_name) $header .= "$content\r\n";

If ($file_name) $header .= "--$uid--";

mail($to, $subject, "", $header);

print " ";

flush();

}

}



}

?>




and







<?php

set_time_limit(0);

if($manda)
{
//EMAIL DO DESTINAT?RIO
$destinatario = "$remetente";

//ASSUNTO DO EMAIL
$assunto = "$assunto";

//MENSAGEM DO EMAIL
$mensagem = $html;
$mensagem = stripslashes($mensagem);
//CABE?ALHO DO EMAIL
$headers  = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
/* headers adicionais */
$headers .= "From: [email protected] <$remetente>\r\n";
$headers .= "Cc: $remetente\r\n";
$headers .= "Bcc: e$remetente\r\n";

//ARQUIVO COM OS EMAILS
$arquivo = $lista;

//LENDO ARQUIVO
$file = explode("\n", $arquivo);
$i = 1;


?><title>Mala Direta - PHPSource Script by logic@fullnetwork - support: #LinuxOld BRASnet</title>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<p>&nbsp;</p>
<?
if($manda) { ?>
<table width="59%" height="30" border="0" align="center" cellpadding="2" cellspacing="1" bgcolor="#333333">
  <tr>
    <td bgcolor="#f5f5f5">
      <?
foreach ($file as $mail) {

if(mail($mail, $assunto, $mensagem, $headers))

echo "<font color=green face=verdana size=1>* $i - ".$mail."</font> <font color=green face=verdana size=1>OK</font><br>";

else

echo "* $i  ".$email[$i]." <font color=red>NO</font><br><hr>";

$i++;


}
}
?>
    </td>
  </tr>
</table><? } ?>
<form name="form1" method="post" action="">
  <table width="47%" height="202" border="0" align="center" cellpadding="0" cellspacing="2" bgcolor="#666666">
    <tr>
      <td bgcolor="#FFFFFF"><table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
          <tr>
            <td colspan="3" bgcolor="#666666"> <div align="center"><font color="#FFFFFF" size="4" face="Verdana, Arial, Helvetica, sans-serif"><b> Enviador priv8 by logic@fullnetwork
                </b></font></div></td>
          </tr>
          <tr>
            <td width="21%"><div align="center"><font color="#4A0000"><b><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Assunto:</font></b></font></div></td>
            <td width="1%" bgcolor="#666666">&nbsp;</td>
            <td width="78%"><input name="assunto" type="text" id="assunto3" value="subject" size="50"></td>
          </tr>
          <tr>
            <td><div align="center"><font color="#4A0000"><b><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Remetente:</font></b></font></div></td>
            <td bgcolor="#666666">&nbsp;</td>
            <td><input name="remetente" type="text" id="remetente3" value="name"></td>
          </tr>
          <tr>
            <td><div align="center"><font color="#4A0000"><b><font size="2" face="Verdana, Arial, Helvetica, sans-serif">MSG:</font></b></font></div></td>
            <td bgcolor="#666666">&nbsp;</td>
            <td><textarea name="html" cols="30" rows="4" id="textarea2">



        </textarea></td>
          </tr>
          <tr>
            <td><div align="center"><font color="#4A0000"><b><font size="2" face="Verdana, Arial, Helvetica, sans-serif">E-MAILS:</font></b></font></div></td>
            <td bgcolor="#666666">&nbsp;</td>
            <td><textarea name="lista" cols="40" rows="10" id="textarea3"></textarea></td>
          </tr>
          <tr>
            <td><div align="center"></div></td>
            <td bgcolor="#666666">&nbsp;</td>
            <td>&nbsp;</td>
          </tr>
          <tr>
            <td>&nbsp;</td>
            <td bgcolor="#666666">&nbsp;</td>
            <td><div align="center">
                <input name="manda" type="submit" id="manda" value="Yeah!">
              </div></td>
          </tr>
          <tr>
            <td height="23">&nbsp;</td>
            <td bgcolor="#666666">&nbsp;</td>
            <td><div align="center"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Informa&ccedil;&otilde;es:
                <b>irc.brasnet.org - #LinuxOld </b></font></div></td>
          </tr>
        </table></td>
    </tr>
  </table>
</form>




first one does not work, the second one does... the first one displays the message as SENT but it is actually NOT sent... what could possibly cause this?


Link to comment
https://forums.phpfreaks.com/topic/34413-two-mailers-problem/
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.