0 Recipients Accepted

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

rickoshea
Forum Newbie
Posts: 4
Joined: Thu Aug 09, 2007 11:46 pm

0 Recipients Accepted

Post by rickoshea »

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


First off, I'll echo the many previous posters who compliment the documentation. Very nicely done.

Setting up and coding for the use of Swiftmail was simple, and straightforward.

That said, I'm lost in trying to solve a problem. Normally I'm of the "look around for the answer until you're sure you can't find it, THEN ask the nice people for their help" school, and that's what I've done. Unfortunately, I'm not familiar enough with Swiftmailer or SMTP to know where else to look...

So, here's the issue:

Everything appears to run fine (see code below), no errors are generated at all. The only problem is, the e-mails don't get sent. The number of recipients accepted that is returned by batchSend is Zero.

Any suggestions? Did I forget to change some Swiftmailer config file somewhere?? Is there some server side thing I'm supposed to do?

Any help is appreciated, especially that help which describes possible fixes to me as though I know nothing about the underlying technology (because I really do know nothing about the underlying technology)

Thank you!

Code: Select all

// these files make it all work!
		require_once "../swift/Swift.php";
		require_once "../swift/Swift/Connection/SMTP.php";
	
		ignore_user_abort(true);
			
				
					$swift =& new Swift(new Swift_Connection_SMTP("smtp.thedomain.com"));
					 
					$message =& new Swift_Message("Hello, Baby", "This is a test");
					 
					$recipients =& new Swift_RecipientList();
					
					foreach($RecipArray as $NewRecip)
					{
						$recipients->addTo($NewRecip);
					}
					 

					$TheNum=$swift->batchSend($message, $recipients, "address@thedomain.com");

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

What does this debug output show?

Code: Select all

// these files make it all work! 
      require_once "../swift/Swift.php"; 
      require_once "../swift/Swift/Connection/SMTP.php"; 
    
      ignore_user_abort(true); 
          
             
               $swift =& new Swift(new Swift_Connection_SMTP("smtp.thedomain.com")); 
                $swift->log->enable();
               $message =& new Swift_Message("Hello, Baby", "This is a test"); 
                
               $recipients =& new Swift_RecipientList(); 
                
               foreach($RecipArray as $NewRecip) 
               { 
                  $recipients->addTo($NewRecip); 
               } 
                

               $TheNum=$swift->batchSend($message, $recipients, "address@thedomain.com"); 
echo "<pre>";
$swift->log->dump();
rickoshea
Forum Newbie
Posts: 4
Joined: Thu Aug 09, 2007 11:46 pm

Post by rickoshea »

The output from the dump:

Code: Select all

++ Enabling logging
>> MAIL FROM: 
<< 250 ok
>> RCPT TO: 
<< 553 sorry, that domain isn't in my list of allowed rcpthosts (#5.7.1)
!! Expected response code(s) [250] but got response [553 sorry, that domain isn't in my list of allowed rcpthosts (#5.7.1)]
>> RSET
<< 250 flushed
>> MAIL FROM: 
<< 250 ok
>> RCPT TO: 
<< 553 sorry, that domain isn't in my list of allowed rcpthosts (#5.7.1)
!! Expected response code(s) [250] but got response [553 sorry, that domain isn't in my list of allowed rcpthosts (#5.7.1)]
>> RSET
<< 250 flushed
>> MAIL FROM: 
<< 250 ok
>> RCPT TO: 
<< 553 sorry, that domain isn't in my list of allowed rcpthosts (#5.7.1)
!! Expected response code(s) [250] but got response [553 sorry, that domain isn't in my list of allowed rcpthosts (#5.7.1)]
>> RSET
<< 250 flushed
So, I assume this is some problem with my SMTP, rather than with the swiftmailer code, is that correct?
rickoshea
Forum Newbie
Posts: 4
Joined: Thu Aug 09, 2007 11:46 pm

Post by rickoshea »

Well, I thought maybe the problem was that I needed to enter values in the Connection/SMTP.php file for username and password- and that wasn't it... Or, if that is it, I'm missing another step:

Code: Select all

Fatal error: 
Uncaught Error of type [swift_connection_exception] with message [Authentication failed using username 'myusername 'and password '********']
@0 swift::swift() in /home/sportsma/public_html/admin/send-newsletter.php on line 167
@1 swift::connect() in /home/sportsma/public_html/swift/Swift.php on line 111
@2 swift::handshake() in /home/sportsma/public_html/swift/Swift.php on line 245

in /home/sportsma/public_html/swift/Swift/Errors.php on line 99
I imagine my questions are rookie level, so please forgive my ignorance...
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

You're using the wrong server. That server must just be for incoming emails to your host, not for outgoing mail. Contact your ISP to ask what your SMTP server should be ;)
rickoshea
Forum Newbie
Posts: 4
Joined: Thu Aug 09, 2007 11:46 pm

Post by rickoshea »

d11wtq wrote:You're using the wrong server. That server must just be for incoming emails to your host, not for outgoing mail. Contact your ISP to ask what your SMTP server should be ;)
Hmmmm... The server address I'm using is the one that was supplied by the hosting company as the outgoing server... But, the host is iPowerWeb and while they give a tremendous amount for the money, their tech support and customer service is awful, so it's possible I was given the wrong information...
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

553 sorry, that domain isn't in my list of allowed rcpthosts (#5.7.1)
This basically tell you that the server isn't authorising you to send email to that address.
evilernie
Forum Newbie
Posts: 12
Joined: Sun Dec 03, 2006 10:43 pm

Post by evilernie »

is there a reason why if i do this, it gives me the error of Fatal error: Call to a member function dump() on a non-object in /var/www/aamr/comments_process.php on line 104

Code: Select all

try {
//Create a Swift instance
$swiftb =& new Swift(new Swift_Connection_SMTP("artintheage.com"));

//Create the sender from the details we've been given
$senderb =& new Swift_Address($email, $name);

//Create the message to send
$messageb =& new Swift_Message("AAMR Comment");
$messageb->attach(new Swift_Message_Part($bodyb));

//Try sending the email
$sentb = $swiftb->send($messageb, "finnegan@gyroworldwide.com", "markh@gyroworldwide.com");

//Disconnect from SMTP, we're done
$swiftb->disconnect();

} catch (Swift_Connection_Exception $e) {
	echo "There was a problem communicating with SMTP: ".$e->getMessage();
}

	echo "<pre>";
	$swiftb->log->dump();
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

I would hazard to guess disconnect() destroyed the logging object reference.
evilernie
Forum Newbie
Posts: 12
Joined: Sun Dec 03, 2006 10:43 pm

Post by evilernie »

ok i commented out the disconnect and i took out the try catch but nothing prints from the dump :-/
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

What does var_dump($swiftb) show? PHP shouldn't care too much about the fact you declared $swiftb in the scope of the try/catch block so I doubt that's the problem.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

Got it. $swiftb is never created because the exception is thrown from the __construct(). That's a pain. I don't know why that never occured to me as a problem until now.

Change for 3.3: Make Swift_Log a singleton, or at least have it register itself somewhere it can accessed.
evilernie
Forum Newbie
Posts: 12
Joined: Sun Dec 03, 2006 10:43 pm

Post by evilernie »

this returns NULL

Code: Select all

try {
//Create a Swift instance
$swiftb =& new Swift(new Swift_Connection_SMTP("artintheage.com"));

//Create the sender from the details we've been given
$senderb =& new Swift_Address($email, $name);

//Create the message to send
$messageb =& new Swift_Message("AAMR Comment");
$messageb->attach(new Swift_Message_Part($bodyb));

//Try sending the email
$sentb = $swiftb->send($messageb, "finnegan@gyroworldwide.com", "markh@gyroworldwide.com");

//Disconnect from SMTP, we're done
//$swiftb->disconnect();
	
} catch (Swift_Connection_Exception $e) {
	echo "<pre>";
	var_dump($swiftb);
	echo "</pre>";
	echo "There was a problem communicating with SMTP: ".$e->getMessage();
}
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

See my last post ;)
evilernie
Forum Newbie
Posts: 12
Joined: Sun Dec 03, 2006 10:43 pm

Post by evilernie »

so how do i fix that? create the instance outside of the try ?
Post Reply