Swift won't send email and won't print any errors either

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
User avatar
Oren
DevNet Resident
Posts: 1640
Joined: Fri Apr 07, 2006 5:13 am
Location: Israel

Swift won't send email and won't print any errors either

Post by Oren »

[SOLVED]

So today I downloaded the latest version of SwiftMailer (2.1.17) and tried to send a simple email, but it failed :cry:
I unzipped it and renamed it "Swift", then I uploaded it to the root of my server. I then created a simple PHP file with the following content and uploaded it to the root as well:

Code: Select all

<?php

require('Swift/Swift.php');
require('Swift/Swift/Connection/SMTP.php');

$mailer = new Swift(new Swift_Connection_SMTP('alpha.dynamized.com'));

//If anything goes wrong you can see what happened in the logs
if($mailer->isConnected()) //Optional
{
    //Sends a simple email
    $mailer->send('"Oren" <[my gmail address here]>',
    '"Oren2" <[my other gmail address]>',
    'Some Subject',
    'Message here'
    );
    //Closes cleanly... works without this but it's not as polite.
    $mailer->close();
} else {
    echo "The mailer failed to connect. Errors: <pre>".print_r($mailer->errors, 1)."</pre><br />
Log: <pre>".print_r($mailer->transactions, 1)."</pre>";
}

?>
I went to this page with my browser, but I got nothing... no errors, no nothing. I checked my mail box and there was nothing new there.
I thought maybe it was a problem with the server or something so I downloaded PHPMailer and tried it too, guess what... It worked - which means that the server is fine and it must be something with Swift and how I used it.

At the beginning of this post I described step by step what I did and in which order so, if anyone can help, that would be great :D
Any help is welcome.
Last edited by Oren on Wed Oct 18, 2006 2:10 pm, edited 1 time in total.
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post by Weirdan »

does it work using

Code: Select all

$mailer->send('my gmail address', 'my other gmail address', 'subject', 'message');
?
User avatar
Oren
DevNet Resident
Posts: 1640
Joined: Fri Apr 07, 2006 5:13 am
Location: Israel

Post by Oren »

What do you mean? I'm already using $mailer->send() :?
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

Oren wrote:What do you mean? I'm already using $mailer->send() :?
He means just using email addresses not "Name" <email@address.com>
User avatar
Oren
DevNet Resident
Posts: 1640
Joined: Fri Apr 07, 2006 5:13 am
Location: Israel

Post by Oren »

Oh, ok... I'll try it and post the result here in few minutes.
User avatar
Oren
DevNet Resident
Posts: 1640
Joined: Fri Apr 07, 2006 5:13 am
Location: Israel

Post by Oren »

Nope, no luck :cry:
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

Can you echo anything out at all below that code? What PHP version do you have?
User avatar
Oren
DevNet Resident
Posts: 1640
Joined: Fri Apr 07, 2006 5:13 am
Location: Israel

Post by Oren »

The PHP version should have been 5.1.6, but somehow it's 4.3.11 :?
Here is what happened: recently, Dynamized moved from cPanel to Interworx which by default, installs PHP 4.3.11 :cry:

I'm going to download SwiftMailer for PHP 4 real quick and I'll post here the results.
User avatar
Oren
DevNet Resident
Posts: 1640
Joined: Fri Apr 07, 2006 5:13 am
Location: Israel

Post by Oren »

Works like a charm, thanks guys :D
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

Heh... how did you know I was leading to the fact Swift has PHP-version specific tarballs? :P

Glad you got it sussed -- now you just need to put your headphones on and listen carefully to the "Swift-is-better-than-phpmailer-swift-is-better-than-phpmailer-swift-is-better-then-phpmailer.mp3" file on repeat-play while you fall asleep. Only then can you make a fair judgement you see :) *cough*
User avatar
Oren
DevNet Resident
Posts: 1640
Joined: Fri Apr 07, 2006 5:13 am
Location: Israel

Post by Oren »

Well, my media player is already set on repat-play, now all I need is a link to download this mp3 file you were talking about :lol:
Post Reply