[PHP] Re: PHP Access Violation using PEAR::Mail_smtp

2004-04-08 Thread Ben Ramsey
So, I found a solution to my problem.  I still do not know what was 
causing the PHP Access Violation errors, but I have an idea, which I 
will relate in this message.

As many suggested, I have pared down my mail sending class by rewriting 
it down to about 250 lines of code.  Previously, the PEAR::Mail::smtp 
class had much fewer lines of code, but if you count all of the other 
files it had to include, then it was a whopping amount of code.  The 
difference here is that I am only using one class now to send mail, 
whereas the PEAR::Mail::smtp class was using about 5 different classes. 
 Let me walk you through them.

Mail::smtp included and extended the Mail class.  The Mail class 
included and extended the PEAR class.  The send() method of Mail::smtp 
included the Net::SMTP class and created an object of that class.  The 
Net::SMTP class included the PEAR and Net::Socket classes (and 
optionally checked for and included the Auth::SASL class).  The 
Net_SMTP() contstructor created a Net::Socket object.  The Net::Socket 
class included and extended the PEAR class.

So, in all, that's about 5 classes that Mail::stmp needed.  Once I got 
it down to one class, the Access Violations disappeared.  So, here's 
what I think was happening with the classes based on some of the 
information I have been told.

I've been told that the Access Violation errors are probably caused when 
PHP tries to access a space of memory that it doesn't have permission to 
access.  From this, I'm gathering that the sheer number of classes 
needed and objects and variables created confused PHP so that it wasn't 
sure what pointers pointed to the correct space in memory.  (Again, I'm 
out on a limb with this guess.)  Because the pointer lost its space in 
memory (I'm guessing that's what happened), PHP tried to access a space 
that it either no longer had permission to access or it never had 
permission to access.

Make sense?  I'm sharing this here because several people expressed an 
interest in knowing how it got resolved.

--
Regards,
 Ben Ramsey
 http://benramsey.com
 http://www.phpcommunity.org/wiki/People/BenRamsey
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Re: PHP Access Violation using PEAR::Mail_smtp

2004-04-06 Thread Ben Ramsey
Let me point something out here: I was a goof and had an authentication 
setting wrong.  When I changed it back to LOGIN, it sends e-mail just 
fine.  So, all is well... sort of.  Every 3rd or 4th run of the script 
still generates the Access Violation message.  However, since it happens 
intermittently, it makes it a pain in the rear to track down.

DVD> Also, you don't need a mailserver on localhost to use mail()

I'm on Windows Server 2003...
Here's the error I get when I use mail() and no SMTP authentication:
Code:
mail("[EMAIL PROTECTED]","This is a test","This is the message");
Error:
Warning: mail() [function.mail]: Failed to connect to mailserver at 
"localhost" port 25, verify your "SMTP" and "smtp_port" setting in 
php.ini or use ini_set() in E:\path\to\test.php on line 5

When I explicitly set the correct mail server with ini_set(), I get:

Warning: mail() [function.mail]: SMTP server response: 550 Relaying is 
prohibited in E:\path\to\test.php on line 6

This is why I've gone with using the PEAR class Mail_smtp.  It seems the 
easiest thing to use without having to write a whole lot of socket 
connection code.

--
Regards,
 Ben Ramsey
 http://benramsey.com
 http://www.phpcommunity.org/wiki/People/BenRamsey
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Re: PHP Access Violation using PEAR::Mail_smtp

2004-04-06 Thread DvDmanDT
Well, the reason noone replies I guess, is that noone knows.. I think your
best bets are to echo the steps in the class, and find exactly what causes
it to crash.. Also, you don't need a mailserver on localhost to use mail()..
I use mail() with my ISP's SMTP server, and I'm on XP (same thing work on
windows Me)..

Post when you find a solution, draws my intrest..

-- 
// DvDmanDT
MSN: dvdmandt¤hotmail.com
Mail: dvdmandt¤telia.com
"Ben Ramsey" <[EMAIL PROTECTED]> skrev i meddelandet
news:[EMAIL PROTECTED]
> I've asked about PHP Access Violation errors before (this very same
> error, as a matter of fact), and every time I ask, I get no response.
> It's been 24 hours, and no one on php-general, pear-general, or #php and
> #pear in Freenode IRC has responded to this particular post.
>
> Do I smell bad?
>
> Please forgive me for refreshing my own post to the list, but this is an
> important question, and it is time-sensitive.  Any help or pointers
> would be greatly appreciated, as I cannot get around this issue at all.
>
> Thanks,
> Ben
>
>
> Ben Ramsey wrote:
>
> > I'm getting the following error when using the Mail_smtp package from
PEAR:
> >
> > PHP has encountered an Access Violation at 0177A8B4
> >
> > It does not occur everytime I use it, but even when send() returns true,
> > e-mail messages are not being sent.  However, it all worked fine a week
> > ago when I was testing it, and I don't think anything has changed to my
> > installation of PHP.
> >
> > I'm using PHP 5RC1 on a Windows Server 2003.  The localhost has no
> > built-in mail functionality, so I cannot use mail().  I must use
> > Mail_smtp to log in to the mail server.  I also have Net_SMTP and
> > Net_Socket installed, and, like I said, when I first dropped in my code,
> > all was working fine.
> >
> > My code is, as follows:
> >
> > 
> > require_once 'Mail/smtp.php';
> >
> > $smtp_settings = array(
> > 'host' => 'localhost',
> > 'port' => '25',
> > 'auth' => 'LOGIN',
> > 'username' => 'username',
> > 'password' => 'password'
> > );
> >
> > $to = "[EMAIL PROTECTED]";
> > $msg = "Line 1\nLine 2\nLine 3";
> > $headers = array(
> > 'Subject'  => "My Subject",
> > 'From' => "[EMAIL PROTECTED]",
> > 'Date' => date('r'),
> > 'Content-Type' => 'text/plain',
> > 'X-Mailer' => "PHP/" . phpversion()
> > );
> >
> > $mail = new Mail_smtp($smtp_settings);
> >
> > if ($mail->send($to, $headers, $msg)) {
> > echo "Sent successfully";
> > } else {
> > echo "Not sent";
> > }
> > 
> >
> > If I don't get the access violation error, I get the message "Sent
> > successfully."  Yet, I don't receive any messages.
> >
> > In the code for Mail_smtp (in Mail/smtp.php), I have added the following
> > line just under the function declaration line for the send() method:
> >
> > echo "test";
> >
> > When the access violation occurs, I get this line:
> >
> > PHP has encountered an Access Violation at 0177A8B4test
> >
> >  From this, it appears to me that the access violation is not occurring
> > when the class tries to send mail, but sometime earlier than that.
> > However, I do not know much more about these Access Violoations, other
> > than PHP is trying to access memory that it doesn't have permission to
> > access.  I couldn't find anything at bugs.php.net or through Google that
> > helped much with this problem.
> >
> > Any help would be greatly appreciated.  I am on a tight deadline, so any
> > help ASAP would be even more greatly appreciated.  ;-)
> >
>
> -- 
> Regards,
>   Ben Ramsey
>   http://benramsey.com
>   http://www.phpcommunity.org/wiki/People/BenRamsey

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Re: PHP Access Violation using PEAR::Mail_smtp

2004-04-06 Thread Tyler Replogle
hey, i think the reason you get no reply is becauase no one knows why it 
happens




From: Ben Ramsey <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED]
Subject: [PHP] Re: PHP Access Violation using PEAR::Mail_smtp
Date: Tue, 06 Apr 2004 14:27:08 -0400
I've asked about PHP Access Violation errors before (this very same error, 
as a matter of fact), and every time I ask, I get no response. It's been 24 
hours, and no one on php-general, pear-general, or #php and #pear in 
Freenode IRC has responded to this particular post.

Do I smell bad?

Please forgive me for refreshing my own post to the list, but this is an 
important question, and it is time-sensitive.  Any help or pointers would 
be greatly appreciated, as I cannot get around this issue at all.

Thanks,
Ben
Ben Ramsey wrote:

I'm getting the following error when using the Mail_smtp package from 
PEAR:

PHP has encountered an Access Violation at 0177A8B4

It does not occur everytime I use it, but even when send() returns true, 
e-mail messages are not being sent.  However, it all worked fine a week 
ago when I was testing it, and I don't think anything has changed to my 
installation of PHP.

I'm using PHP 5RC1 on a Windows Server 2003.  The localhost has no 
built-in mail functionality, so I cannot use mail().  I must use Mail_smtp 
to log in to the mail server.  I also have Net_SMTP and Net_Socket 
installed, and, like I said, when I first dropped in my code, all was 
working fine.

My code is, as follows:


require_once 'Mail/smtp.php';
$smtp_settings = array(
'host' => 'localhost',
'port' => '25',
'auth' => 'LOGIN',
'username' => 'username',
'password' => 'password'
);
$to = "[EMAIL PROTECTED]";
$msg = "Line 1\nLine 2\nLine 3";
$headers = array(
'Subject'  => "My Subject",
'From' => "[EMAIL PROTECTED]",
'Date' => date('r'),
'Content-Type' => 'text/plain',
'X-Mailer' => "PHP/" . phpversion()
);
$mail = new Mail_smtp($smtp_settings);

if ($mail->send($to, $headers, $msg)) {
echo "Sent successfully";
} else {
echo "Not sent";
}

If I don't get the access violation error, I get the message "Sent 
successfully."  Yet, I don't receive any messages.

In the code for Mail_smtp (in Mail/smtp.php), I have added the following 
line just under the function declaration line for the send() method:

echo "test";

When the access violation occurs, I get this line:

PHP has encountered an Access Violation at 0177A8B4test

 From this, it appears to me that the access violation is not occurring 
when the class tries to send mail, but sometime earlier than that. 
However, I do not know much more about these Access Violoations, other 
than PHP is trying to access memory that it doesn't have permission to 
access.  I couldn't find anything at bugs.php.net or through Google that 
helped much with this problem.

Any help would be greatly appreciated.  I am on a tight deadline, so any 
help ASAP would be even more greatly appreciated.  ;-)

--
Regards,
 Ben Ramsey
 http://benramsey.com
 http://www.phpcommunity.org/wiki/People/BenRamsey
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
_
Tax headache? MSN Money provides relief with tax tips, tools, IRS forms and 
more! http://moneycentral.msn.com/tax/workshop/welcome.asp

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Re: PHP Access Violation using PEAR::Mail_smtp

2004-04-06 Thread Ben Ramsey
I've asked about PHP Access Violation errors before (this very same 
error, as a matter of fact), and every time I ask, I get no response. 
It's been 24 hours, and no one on php-general, pear-general, or #php and 
#pear in Freenode IRC has responded to this particular post.

Do I smell bad?

Please forgive me for refreshing my own post to the list, but this is an 
important question, and it is time-sensitive.  Any help or pointers 
would be greatly appreciated, as I cannot get around this issue at all.

Thanks,
Ben
Ben Ramsey wrote:

I'm getting the following error when using the Mail_smtp package from PEAR:

PHP has encountered an Access Violation at 0177A8B4

It does not occur everytime I use it, but even when send() returns true, 
e-mail messages are not being sent.  However, it all worked fine a week 
ago when I was testing it, and I don't think anything has changed to my 
installation of PHP.

I'm using PHP 5RC1 on a Windows Server 2003.  The localhost has no 
built-in mail functionality, so I cannot use mail().  I must use 
Mail_smtp to log in to the mail server.  I also have Net_SMTP and 
Net_Socket installed, and, like I said, when I first dropped in my code, 
all was working fine.

My code is, as follows:


require_once 'Mail/smtp.php';
$smtp_settings = array(
'host' => 'localhost',
'port' => '25',
'auth' => 'LOGIN',
'username' => 'username',
'password' => 'password'
);
$to = "[EMAIL PROTECTED]";
$msg = "Line 1\nLine 2\nLine 3";
$headers = array(
'Subject'  => "My Subject",
'From' => "[EMAIL PROTECTED]",
'Date' => date('r'),
'Content-Type' => 'text/plain',
'X-Mailer' => "PHP/" . phpversion()
);
$mail = new Mail_smtp($smtp_settings);

if ($mail->send($to, $headers, $msg)) {
echo "Sent successfully";
} else {
echo "Not sent";
}

If I don't get the access violation error, I get the message "Sent 
successfully."  Yet, I don't receive any messages.

In the code for Mail_smtp (in Mail/smtp.php), I have added the following 
line just under the function declaration line for the send() method:

echo "test";

When the access violation occurs, I get this line:

PHP has encountered an Access Violation at 0177A8B4test

 From this, it appears to me that the access violation is not occurring 
when the class tries to send mail, but sometime earlier than that. 
However, I do not know much more about these Access Violoations, other 
than PHP is trying to access memory that it doesn't have permission to 
access.  I couldn't find anything at bugs.php.net or through Google that 
helped much with this problem.

Any help would be greatly appreciated.  I am on a tight deadline, so any 
help ASAP would be even more greatly appreciated.  ;-)

--
Regards,
 Ben Ramsey
 http://benramsey.com
 http://www.phpcommunity.org/wiki/People/BenRamsey
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php