Mail sent twice but only to Hotmail

Swift Mailer is a fantastic library for sending email with php. Discuss this library or ask any questions about it here.

Moderators: Chris Corbyn, General Moderators

Post Reply
david7441
Forum Newbie
Posts: 2
Joined: Tue May 12, 2009 5:40 am

Mail sent twice but only to Hotmail

Post by david7441 »

Hi

I've just started trying out Swift Mailer which is perfect for my project but I have hit a problem with my first test.

I took a chunk of code out of the manual (Using the send() Method - http://swiftmailer.org/docs/send-method)
The only thing I added were my details and an addPart (makes no difference if I remove this).
I have a blueyonder.co.uk email account and a Hotmail account so I used both for the test. When I run the test, the message at the bottom of the code reported 2 messages sent. But 3 arrive. The blueyonder one gets there fine - one email. The hotmail account receives two.

Code: Select all

 
<?php
 
require_once 'lib/swift_required.php';
 
//Create the Transport
$transport = Swift_SmtpTransport::newInstance('mail.********.com', 25)
  ->setUsername('info@********.com')
  ->setPassword('********')
  ;
 
//Create the Mailer using your created Transport
$mailer = Swift_Mailer::newInstance($transport);
 
//Create a message
$message = Swift_Message::newInstance('Wonderful Subject')
  ->setFrom(array('info@******.com' => '******'))
  ->setTo(array('********@hotmail.com', '********@blueyonder.co.uk' => '********'))
  ->setBody('Here is the message itself')
  //And optionally an html body
  ->addPart('<strong>Here is the message itself</strong>', 'text/html')
  ;
  
//Send the message
$numSent = $mailer->send($message);
 
printf("Sent %d messages\n", $numSent);
 
/* Note that often that only the boolean equivalent of the return value is of concern (zero indicates FALSE)*/
   
if ($mailer->send($message))
{
  echo "Sent\n";
}
else
{
  echo "Failed\n";
}
 
?>
 
I guess it'd make more sense if both accounts received it twice. As I've used the manual code intact it's hard to see what I've done wrong. Have I misunderstood something?

I'm using Php 5.2.9 set with an .htaccess file which is working (ran phpinfo() to check).
Php 4.4.9 is used elsewhere on the site but this test is in a separate folder along with the library and the .htaccess file.

Any help appreciated

David
Last edited by Benjamin on Tue May 12, 2009 11:43 am, edited 1 time in total.
Reason: Changed code type from text to php.
david7441
Forum Newbie
Posts: 2
Joined: Tue May 12, 2009 5:40 am

Re: Mail sent twice but only to Hotmail

Post by david7441 »

Hi

Tests with Swift Mailer version 3.3.3 with php 4 seem to work OK - only ONE email to Hotmail.
Guess I'll have to use that unless someone can tell me why I get two copies in my Hotmail account.

David
Post Reply