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
kigoobe
Forum Commoner
Posts: 38 Joined: Mon Jul 10, 2006 3:26 am
Post
by kigoobe » Wed Nov 15, 2006 8:31 am
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>";
kigoobe
Forum Commoner
Posts: 38 Joined: Mon Jul 10, 2006 3:26 am
Post
by kigoobe » Wed Nov 15, 2006 9:13 am
Forgot to mention, I am also getting a mail sent message along with the error message. But, no message is received ...
kigoobe
Forum Commoner
Posts: 38 Joined: Mon Jul 10, 2006 3:26 am
Post
by kigoobe » Wed Nov 15, 2006 10:13 am
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
JayBird
Admin
Posts: 4524 Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:
Post
by JayBird » Wed Nov 15, 2006 10:20 am
Are you using PHP 4 or 5, and if so have you got the correct version of Swift?
kigoobe
Forum Commoner
Posts: 38 Joined: Mon Jul 10, 2006 3:26 am
Post
by kigoobe » Wed Nov 15, 2006 10:32 am
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 ...
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098 Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia
Post
by Chris Corbyn » Wed Nov 15, 2006 10:42 am
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:
But I'm confused; what's in $_POST['moncor']; ? Is it just one address?
kigoobe
Forum Commoner
Posts: 38 Joined: Mon Jul 10, 2006 3:26 am
Post
by kigoobe » Wed Nov 15, 2006 11:29 am
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?
kigoobe
Forum Commoner
Posts: 38 Joined: Mon Jul 10, 2006 3:26 am
Post
by kigoobe » Wed Nov 15, 2006 11:43 am
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.
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098 Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia
Post
by Chris Corbyn » Wed Nov 15, 2006 12:32 pm
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.
kigoobe
Forum Commoner
Posts: 38 Joined: Mon Jul 10, 2006 3:26 am
Post
by kigoobe » Wed Nov 15, 2006 1:56 pm
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.
kigoobe
Forum Commoner
Posts: 38 Joined: Mon Jul 10, 2006 3:26 am
Post
by kigoobe » Wed Nov 15, 2006 4:05 pm
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
)
)
kigoobe
Forum Commoner
Posts: 38 Joined: Mon Jul 10, 2006 3:26 am
Post
by kigoobe » Wed Nov 15, 2006 4:22 pm
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 ???
kigoobe
Forum Commoner
Posts: 38 Joined: Mon Jul 10, 2006 3:26 am
Post
by kigoobe » Thu Nov 16, 2006 4:19 pm
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.
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098 Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia
Post
by Chris Corbyn » Thu Nov 16, 2006 5:19 pm
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