Page 1 of 2

Anyone having Undefined offset error with 2.1.17?

Posted: Wed Nov 15, 2006 8:31 am
by kigoobe
I tried using version 2.1.17, and here's the error I got -

Code: Select all

Notice: Undefined offset: 1 in /home/jsmith/public_html/Swift-2.1.17-php4/Swift.php on line 1360
The code that's producing the error is

Code: Select all

require('Swift-2.1.17-php4/Swift.php');
require('Swift-2.1.17-php4/Swift/Swift_Sendmail_Connection.php');

$connection = new Swift_Sendmail_Connection;
$mailer = new Swift($connection, $_SERVER['SERVER_NAME']);


//Container for recipients
$recipients = array();
$recipients[] = array($_POST['moncor']);

if ($mailer->isConnected())
{
    //Pass the array to send()
    $mailer->send(
        $recipients,
        $sender,
        $objetcordo,
        $themessage
    );
   	$mailer->close();
	?>
	<h5 align="center" style="color:#006DC6;">Your mail has been sent</h5>
	<div class="taille2" style="margin-bottom:30px;">
	Bonjour <?=$prenom?> <?=$nom?><br /><br />
	Your mail has been sent to<br /><br />
	<?php
	$language = $_POST['moncor'];
    $n = count($language);
    $i = 0;
	?>
	<div style="width:700px;align:left;">
	<?php
	echo "<ol>";
   while ($i < $n)
   {
      echo "<li>{$language[$i]}</li> \r\n";
      $i++;
   }
   echo "</ol>";
	?>
	</div>
	<br /><br />
	<a href="<?=$thelink?>.php" class="box">Retour</a>
	</div>
	<?php
}
else echo "The mailer failed to connect. Errors: <pre>".print_r($mailer->errors, 1)."</pre><br />
	Log: <pre>".print_r($mailer->transactions, 1)."</pre>";

Posted: Wed Nov 15, 2006 9:13 am
by kigoobe
Forgot to mention, I am also getting a mail sent message along with the error message. But, no message is received ...

Posted: Wed Nov 15, 2006 10:13 am
by kigoobe
Well, and when I try adding the Swift_Template_Plugin.php, I get

Code: Select all

Parse error: syntax error, unexpected T_STRING, expecting '{' in /home/jsmith/public_html/Swift_Template_Plugin.php on line 3

Posted: Wed Nov 15, 2006 10:20 am
by JayBird
Are you using PHP 4 or 5, and if so have you got the correct version of Swift?

Posted: Wed Nov 15, 2006 10:32 am
by kigoobe
Thanks Jaybird. I am using php4, and using correct version of Swiftmail...

Well, I think I found the problem (well, partially). I was using SM 1.3x versions naming conventions in SM 2.x. Found it while searching the net, now I have changed the two lines to

Code: Select all

require('Swift-2.1.17-php4/Swift/Connection/Sendmail.php');
and

Code: Select all

$connection = new Swift_Connection_Sendmail;
With this, I am getting no error message, but I don't receive the email as well. Now it's appearing more weird, as I don't have an error message ... :roll:

Posted: Wed Nov 15, 2006 10:42 am
by Chris Corbyn
You're populating the array wrong. It's either a one dimensional array with just email addresses, or a two dimensional array with e-mail addresses and names:

Code: Select all

$recipients[] = $_POST['moncor'];
But I'm confused; what's in $_POST['moncor']; ? Is it just one address?

Posted: Wed Nov 15, 2006 11:29 am
by kigoobe
thanks d11.

Its an array basically, $firstname.' '.$lasname.', '.$email of multiple members.

So it's becoming a 2 dimentional array. Right? Am I doing anything wrong? Well must be, but can you see anything please?

Posted: Wed Nov 15, 2006 11:43 am
by kigoobe
well, may be I have got some clues ...

On doing

Code: Select all

print "Log: <pre>".print_r($mailer->transactions, 1)."</pre>";
just after sending the mail, I got this -

Code: Select all

Log: 
Array
(
    [0] => Array
        (
            [command] => 
            [time] => 0.11251200 1163612483
            [response] => 220-kgb.kigoobe.com ESMTP Exim 4.52 #1 Wed, 15 Nov 2006 18:41:23 +0100 
220-We do not authorize the use of this system to transport unsolicited, 
220 and/or bulk e-mail.

        )

    [1] => Array
        (
            [command] => EHLO http://www.probtp-parrainage.com

            [time] => 0.11773700 1163612483
            [response] => 250-kgb.kigoobe.com Hello nobody at http://www.probtp-parrainage.com
250-SIZE 52428800
250-PIPELINING
250-AUTH PLAIN LOGIN
250-STARTTLS
250 HELP

        )

    [2] => Array
        (
            [command] => MAIL FROM: 

            [time] => 0.11872900 1163612483
            [response] => 250 OK

        )

    [3] => Array
        (
            [command] => RCPT TO: "Array" <>

            [time] => 0.11890800 1163612483
            [response] => 501 "Array" <>: missing or malformed local part

        )

    [4] => Array
        (
            [command] => RSET

            [time] => 0.11908800 1163612483
            [response] => 250 Reset OK

        )

    [5] => Array
        (
            [command] => QUIT

            [time] => 0.11936900 1163612483
            [response] => 221 kgb.kigoobe.com closing connection

        )

)
Does it clear the situation?

Thanks again.

Posted: Wed Nov 15, 2006 12:32 pm
by Chris Corbyn
That's with the updated code I gave you you're getting that? Can you show me a print_r() of $_POST['moncor'] ? If it's already an array, then you probably won't want to put it inside another array like you're doing now.

Posted: Wed Nov 15, 2006 1:56 pm
by kigoobe
Thanks ... following what you told, I did like this -

Code: Select all

$recipients = array();
$recipients[] = $_POST['moncor'];
print_r($recipients);
And I got this

Code: Select all

Array ( [0] => Array ( [0] => George Bush, georgew@bush.com [1] => Bill Clinton, bill@clinton.com ) )
Then,
I changed that to -

Code: Select all

$recipients = array();
$recipients[] = array($_POST['moncor']);
print_r($_POST['moncor']);// '1='.$_POST['moncor'].'<br />';
print_r($recipients);// '2='.array($_POST['moncor']).'<br />';
And I got this -

Code: Select all

Array ( [0] => George Bush, bush@bush.com [1] => Bill Clinton, bill@bill.com ) // and
Array ( [0] => Array ( [0] => Array ( [0] => George Bush, bush@bush.com [1] => Bill Clinton, bill@bill.com  ) ) )
Thanks again.

Posted: Wed Nov 15, 2006 2:33 pm
by Chris Corbyn
The format should be:

Array ( [0] => Array ( [0] => George Bush, [1] => georgew@bush.com ), [1] => Array ( [0] => Bill Clinton, [1] => bill@clinton.com ) )

Or just:

Array ( [0] => George Bush <georgew@bush.com>, [1] => Bill Clinton <bill@clinton.com> )

Posted: Wed Nov 15, 2006 4:05 pm
by kigoobe
Thanks again d11. Using

Code: Select all

Array ( [0] => George Bush <georgew@bush.com>, [1] => Bill Clinton <bill@clinton.com> )
I got this

Code: Select all

Log: 
Array
(
    [0] => Array
        (
            [command] => 
            [time] => 0.68216800 1163628068
            [response] => 220-kgb.kigoobe.com ESMTP Exim 4.52 #1 Wed, 15 Nov 2006 23:01:08 +0100 
220-We do not authorize the use of this system to transport unsolicited, 
220 and/or bulk e-mail.

        )

    [1] => Array
        (
            [command] => EHLO http://www.probtp-parrainage.com

            [time] => 0.68459900 1163628068
            [response] => 250-kgb.kigoobe.com Hello nobody at http://www.probtp-parrainage.com
250-SIZE 52428800
250-PIPELINING
250-AUTH PLAIN LOGIN
250-STARTTLS
250 HELP

        )

    [2] => Array
        (
            [command] => MAIL FROM: 

            [time] => 0.68546300 1163628068
            [response] => 250 OK

        )

    [3] => Array
        (
            [command] => RCPT TO: 

            [time] => 0.68562700 1163628068
            [response] => 501 : "@" or "." expected after "George"

        )

    [4] => Array
        (
            [command] => RSET

            [time] => 0.68582400 1163628068
            [response] => 250 Reset OK

        )

    [5] => Array
        (
            [command] => MAIL FROM: 

            [time] => 0.68623200 1163628068
            [response] => 250 OK

        )

    [6] => Array
        (
            [command] => RCPT TO: 

            [time] => 0.68636900 1163628068
            [response] => 501 : "@" or "." expected after "Bill"

        )

    [7] => Array
        (
            [command] => RSET

            [time] => 0.68653800 1163628068
            [response] => 250 Reset OK

        )

    [8] => Array
        (
            [command] => QUIT

            [time] => 0.68676200 1163628068
            [response] => 221 kgb.kigoobe.com closing connection

        )

)

Posted: Wed Nov 15, 2006 4:22 pm
by kigoobe
while searching, i got an article > http://support.microsoft.com/?id=291828 ... seemes that the MS servers r having a similar problem ... but i'm using a linux RHEL. or the problem is getting duplicated elsewhere ???

Posted: Thu Nov 16, 2006 4:19 pm
by kigoobe
well, the script is working now, I have changed the array elements from $forename.' '.$lastname.', '.$email to $email only, and it works like a charm ... since I don't have the otehr option, I will go with this solution, though I would have liked to get the previous solution.

Also, other problem what I was thinking about, even when the mail doesn't go, I get my 'mail sent message' ... this is weird, as if the mail doesn't go, the message shouldn't come ...

Anyway, thanks for all the help, and thanks to Chris for providing such a wonderful tool in open source.

Posted: Thu Nov 16, 2006 5:19 pm
by Chris Corbyn
Did you have the comma in there without the < > ?

Also, to check if the mail sent you should be checking for a TRUE return value from send(). You don't check anything presently ;)