Page 1 of 1

phpMailer sending email twice

Posted: Thu Oct 01, 2009 3:26 pm
by Deborah0311
I have been dealing with this all day. I have no idea why this is sending a duplicate email. I have some code at the bottom that checks if the script runs twice, which is does. I have taken parts out, put other parts in, etc. To no avail - the email keeps coming twice.

The image and vars are sent from flash -

Any help is appreciated!

Code: Select all

 
<?php
 
require_once("class.phpmailer.php");
 
$mail = new PHPMailer();
 
// don't use this line of code for godaddy.com
//$mail->IsSMTP();
 
// set mailer to use godaddy relay server
$mail->Host = "relay-hosting.secureserver.net";
 
//this gets the image from flash
if (isset($GLOBALS["HTTP_RAW_POST_DATA"])) {
    //$fullFilePath = dirname(__FILE__) . "/" . $_GET['name'];
    $fullFilePath = $_GET['img'];
    $handle = fopen($fullFilePath,"w");
    fwrite($handle, $GLOBALS["HTTP_RAW_POST_DATA"]);
    fclose($handle);
    
} else {
    echo 'An Error has occurred';
}
    $sTo = $_GET['sTo'];
    $sFrom = $_GET['sFrom'];
    $sMsg = $_GET['sMsg'];
    
    $date           = date("m/d/Y H:i:s");
    $lb = "\n";
    $sp = "  ";
    
    $mail->From = $sFrom;
    $mail->FromName = $sFrom;
    $mail->AddAddress($sTo);
    $mail->AddReplyTo($sFrom);
    
    $mail->WordWrap = 50;
    //$mail->AddAttachment($jpg);
    $mail->IsHTML(true);
    $mail->Subject = "Halloween Greeting";
    $mail->AddEmbeddedImage("mydrawing.jpg", "mydrawing.jpg", "mydrawing.jpg", "base64", "image/jpg"); 
    $mail->Body = '
    <html>
    <table width="100%" cellpadding="10" cellspacing="0" class="backgroundTable" bgcolor="#FFFFFF">
        <tr>
            <td valign="top" align="center">
                <img src="cid:mydrawing.jpg" alt="Happy Halloween from Kiwemail.com">
            </td>
        </tr>
        <tr>
            <td valign="top" align="center">
                <p>Sent from <a href="http://www.kiwemail.com/halloween/index.php" target="_self">Kiwemail.com</a></p>
            </td>
        </tr>
    </table>
    </html>';
    
    
    if ($mail->Send()){
        unset($mail);
        include('success.php');
    } else {
        echo "an Error happened";
    }
    
 
$data =  $sTo .$sp .$sFrom .$sp .$sMsg .$sp .$date .$lb;
file_put_contents('ecard_log.txt', $data, FILE_APPEND);
$mydata = "the script ran " .$date .$lb;
file_put_contents('script.txt', $mydata, FILE_APPEND);
 
 
?>

Re: phpMailer sending email twice

Posted: Mon Oct 05, 2009 10:58 am
by robnet
So are you saying you get two new entries in each of the text files you reference at the bottom of your code?
If so it sounds like your script is being called twice. - Perhaps worth checking your flash?