phpMailer sending email twice

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Deborah0311
Forum Newbie
Posts: 1
Joined: Thu Oct 01, 2009 3:18 pm

phpMailer sending email twice

Post 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);
 
 
?>
robnet
Forum Commoner
Posts: 85
Joined: Mon Aug 10, 2009 8:32 am
Location: South East, UK

Re: phpMailer sending email twice

Post 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?
Post Reply