Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

I can't send E-mail in OScommerce


Guest

Recommended Posts

  • Replies 64
  • Created
  • Last Reply

Hi,

 

Do you have the PHP errors going to a file called 'error_log', or possibly another file ?

 

Any error messages that you can supply, other than the "403" (forbidden), sounds like a path permissions problem ?

 

Peter

Link to comment
Share on other sites

Do you have the PHP errors going to a file called 'error_log', or possibly another file ?

 

Any error messages that you can supply, other than the "403" (forbidden), sounds like a path permissions problem ?

 

No any error in this page, but it auto direct to forbidden.php file

Link to comment
Share on other sites

Hi,

 

Well there is no such file supplied with a 'stock/standard' osCommerce, so you must have this in your .htaccess file

 

ErrorDocument 404 http://localhost/catalog/admin/forbiden.php

 

....... or similar. :)

 

You may get better answers to this problem on a PHP forum, because it is not osCommerce that is the problem. There are so many factors to compound the problem, because you are not running osCommerce from a domain/server, it sounds like it is being run from your home computer. You may be running Apache under Windows, or running a Linux box, or running PHPdev, or ....,etc,etc.

 

I always get very good replies/answers to problems like this at the Sitepoint forums, just register and post your questions at:

 

http://www.sitepoint.com/forums/forumdisplay.php?f=34

 

there are many PHP gurus there, who no doubt have done what you are tring to do.

 

Peter

 

edit:try a google on string "mail::factory authenticate", there are some interesting posts there.

Link to comment
Share on other sites

You may need to tell Mail::factory where your sendmail is, like:

 

 

CODE 

 

$params['sendmail_path'] = '/usr/lib/sendmail';

 

Is it used Sendmail function ?!

Link to comment
Share on other sites

Hi Peterr,

 

I tried to use this code save as sendmail.php

 

<?php

include('Mail.php');

 

$recipients = 'Toni Wong';

 

$headers['From']    = '[email protected]';

$headers['To']      = '[email protected]';

$headers['Subject'] = 'Test message of sendmail';

 

$params["host"] = "smtp.on-nets.com";

$params["port"] = "25";

$params["auth"] = true;

$params["username"] = "[email protected]";

$params["password"] = "xxxx";

 

$body = 'Test message';

 

$params['sendmail_path'] = '/usr/lib/sendmail';

 

// Create the mail object using the Mail::factory method

$mail_object =& Mail::factory('sendmail', $params);

 

$mail_object->send($recipients, $headers, $body);

?>

 

 

I try to load this page, it hasn't any response.

Just reply the blank page!

And no email received.

 

what's happened?

Link to comment
Share on other sites

Hi Peter,

 

I still have the problem.

 

I add this code in /admin/includes/classes/email.php

 

include("Mail.php");

 

$recipients = "$to";

 

$headers["From"]    = $from;

$headers["To"]      = $to;

$headers["Subject"] = $subject;

 

$params["host"] = "smtp.on-nets.com";

$params["port"] = "25";

$params["auth"] = true;

$params["username"] = "[email protected]";

$params["password"] = "xxxx";

 

// Create the mail object using the Mail::factory method

$mail_object =& Mail::factory("smtp", $params);

 

$mail_object->send($recipients, $headers, $body);

 

 

Inserted before

if (EMAIL_TRANSPORT == 'smtp') {

 

        return mail($to_addr, $subject, $this->output, 'From: ' . $from . $this->lf . 'To: ' . $to . $this->lf . implode($this->lf, $this->headers) . $this->lf . implode($this->lf, $xtra_headers));

 

      } else {

 

        return mail($to, $subject, $this->output, 'From: '.$from.$this->lf.implode($this->lf, $this->headers).$this->lf.implode($this->lf, $xtra_headers));

 

      }

 

 

 

Now, it can send the email to my email address.

But it hasn't content.

 

Why?! What is missing?!

 

Thanks~

Link to comment
Share on other sites

$params["host"] = "smtp.on-nets.com";

$params["port"] = "25";

$params["auth"] = true;

$params["username"] = "[email protected]";

$params["password"] = "xxxx";

 

$body = $this->output;

 

 

Oh....I know that la.... :D

 

the body is $ this->output

 

 

 

hahahahaha ^_^

Link to comment
Share on other sites

  • 1 year later...

Hello...installed the SMTP contribution using Mail.php and i get this

 

Fatal error: Cannot redeclare tep_db_connect() (previously declared in C:\webspace\maximiliano\producto\productoscristianos.com.ar\www\carrito\admin\includes\functions\database.php:13) in C:\webspace\maximiliano\producto\productoscristianos.com.ar\www\carrito\admin\includes\functions\database.php on line 25

 

Changed config of both email.php files to

$headers["From"] = $from;

$headers["To"] = $to_addr;

$headers["Subject"] = $subject;

$headers["Bcc"] = "[email protected]";

$params["host"] = "mail.productoscristianos.com.ar";

$params["port"] = "25";

$params["auth"] = true;

$params["username"] = "[email protected]";

$params["password"] = "xxxxxx";

 

I used the test.php by my own with same config and is working great, but oscommerce refuses to work, jeje

 

Any HElp?

Link to comment
Share on other sites

Hello...installed the SMTP contribution using Mail.php and i get this

 

Fatal error: Cannot redeclare tep_db_connect() (previously declared in C:\webspace\maximiliano\producto\productoscristianos.com.ar\www\carrito\admin\includes\functions\database.php:13) in C:\webspace\maximiliano\producto\productoscristianos.com.ar\www\carrito\admin\includes\functions\database.php on line 25

 

Changed config of both email.php files to

    $headers["From"]    = $from;

    $headers["To"]      = $to_addr;

    $headers["Subject"] = $subject;

    $headers["Bcc"] = "[email protected]";

    $params["host"] = "mail.productoscristianos.com.ar";

    $params["port"] = "25";

    $params["auth"] = true;

    $params["username"] = "[email protected]";

    $params["password"] = "xxxxxx";

 

I used the test.php by my own with same config and is working great, but oscommerce refuses to work, jeje

 

Any HElp?

 

 

Well the error is telling you that the function tep_db_connect is being declared more than once.

 

So obviously somewhere in your code it is calling

 

require(database.php) more than once in your code somewhere. Now it could be in the same file or it could be in another file that your current file calls with require();

 

Go through your code from the top, if you see a require(database.php) somewhere comment it out with // at the start of the line.

 

Test if things work after that.

 

If not then look at all the require() statements, some of the files are trying to call the database.php more than once. (this assumes you did not change the database.php file in any way)

Link to comment
Share on other sites

OK i solved the problem but the send mail dialog in Tools admin box throws me this...

Fatal error: Class 'Mail' not found in C:\webspace\maximiliano\producto\productoscristianos.com.ar\www\carrito\admin\includes\classes\email.php on line 515

 

This is the code

require_once 'Mail.php';

 

$user_contact = '[email protected]';

$headers["From"] = $from;

$headers["To"] = $to_addr;

$headers["Subject"] = $subject;

$headers["Bcc"] = "[email protected]";

$params["host"] = "mail.productoscristianos.com.ar";

$params["port"] = "25";

$params["auth"] = true;

$params["username"] = "[email protected]";

$params["password"] = "favalli";

 

// Create the mail object using the Mail::factory method

$mail_object =& Mail::factory("smtp", $params);

return $mail_object->send("$to_addr, [email protected]", $headers, $this->output);

 

I have my Test.php in the same folder and it delivers OK and the frontend mails are delivered ok too...

 

Any help?

 

Thanks a lot for your help!!!

 

PS: i my host is a NT Server and uses PHP5 :(

Link to comment
Share on other sites

Hey guys, this error occurs when i try to send an enail from the admnin area

 

Fatal error: Class 'Mail' not found in C:\webspace\maximiliano\producto\productoscristianos.com.ar\www\carrito\admin\includes\classes\email.php on line 515

 

but frontend emails works ok...

 

Any help?

 

CODE

require_once 'Mail.php';

 

$user_contact = '[email protected]';

$headers["From"] = $from;

$headers["To"] = $to_addr;

$headers["Subject"] = $subject;

$headers["Bcc"] = "[email protected]";

$params["host"] = "mail.productoscristianos.com.ar";

$params["port"] = "25";

$params["auth"] = true;

$params["username"] = "[email protected]";

$params["password"] = "xxxxxxi";

 

// Create the mail object using the Mail::factory method

$mail_object =& Mail::factory("smtp", $params);

return $mail_object->send("$to_addr, [email protected]", $headers, $this->output);

Link to comment
Share on other sites

Just to shed light on one of the issues here in case people are still stuck on "Cannot redeclare tep_db_connect()". I was running into this error on the admin side. It seems to be due to the new code's reference to mail.php, which includes application_top.php. Since this appears twice on the page, tep_db_connect() is declared twice... I fixed it by changing line 13 in mail.php to

 

require_once('includes/application_top.php');

 

Now I'm getting this error, the same as Razor7:

 

Fatal error: Class 'Mail' not found in [...]\includes\classes\email.php on line 515

Link to comment
Share on other sites

Just to shed light on one of the issues here in case people are still stuck on "Cannot redeclare tep_db_connect()". I was running into this error on the admin side. It seems to be due to the new code's reference to mail.php, which includes application_top.php. Since this appears twice on the page, tep_db_connect() is declared twice... I fixed it by changing line 13 in mail.php to

 

  require_once('includes/application_top.php');

 

Now I'm getting this error, the same as Razor7:

 

Fatal error: Class 'Mail' not found in [...]\includes\classes\email.php on line 515

 

Was curious about this one so I downloaded that Mail::factory contrib.

 

Now it tells you to replace the current email.php files which sit in

 

admin/includes/classes

 

and

 

includes/classes

 

and the code in these

 

require_once 'Mail.php';

$user_contact = '[email protected]';
$headers["From"] = $from;
$headers["To"] = $to_addr;
$headers["Subject"] = $subject;
$headers["Bcc"] = "[email protected]";
$params["host"] = "mail.productoscristianos.com.ar";
$params["port"] = "25";
$params["auth"] = true;
$params["username"] = "[email protected]";
$params["password"] = "xxxxxxi"

 

the only mail.php file that exists is in admin/

 

2 things the require statement would need to point to the relevant directory to pick it up

 

require_once "../../mail.php"; for the one in admin/includes/classes/

 

and

 

require_once "../../admin/mail.php"; for the one in includes/classes/

 

but before you all rush off to try it mail.php does NOT declare a class called Mail and there is certainly no factory function defined, hence the error.

 

I would say there is a file missing here. namely the one that defines the class Mail{}

is the contribution incomplete? does it require something else to be installed first?

Link to comment
Share on other sites

The Mail class is PHP native, so nothing is missing, also, the same code is working for the frontend, so customers are creating new accounts and requesting invoices and everything is OK with this Mail class native on PHP, but the backend just doesn?t works. That's the problem, not the contribution.

 

Regards.

Link to comment
Share on other sites

The Mail class is PHP native, so nothing is missing, also, the same code is working for the frontend, so customers are creating new accounts and requesting invoices and everything is OK with this Mail class native on PHP, but the backend just doesn?t works. That's the problem, not the contribution.

 

Regards.

 

ah, maybe not. I was aware of a mail() function in core PHP but not a mail class. So had a look at www.php.net under the mail() page in the manual someone had added a comment about a PEAR object (which is where the Mail class comes in).

 

Now it says that PEAR is installed as of PHP 4.0.3. But maybe not if your host has a custom install so first thing to do be to check if PEAR is in your installation. If it is there will be no problem calling Mail::factory

 

Also the code in the example on the PHP site is the same one being banded about here. That line require "Mail.php"; just doesnt make sense to me, the file doesnt exist where it is being called from. It would seem people just copied that could without understanding exactly what it was doing

 

heres the extract from php.net

 

If you can't use or don't understand how to use the sendmail program from linux, you can use a PEAR object to send mail.

 

<?

include("Mail.php");

 

$recipients = "[email protected]";

 

$headers["From"]    = "[email protected]";

$headers["To"]      = "[email protected]";

$headers["Subject"] = "Test message";

 

$body = "TEST MESSAGE!!!";

 

$params["host"] = "smtp.server";

$params["port"] = "25";

$params["auth"] = true;

$params["username"] = "user";

$params["password"] = "password";

 

// Create the mail object using the Mail::factory method

$mail_object =& Mail::factory("smtp", $params);

 

$mail_object->send($recipients, $headers, $body);

?>

 

In my case, i use a smtp server that require authentication, and sendmail configuration is almost cryptic to me.

 

PEAR is already installed in PHP 4.0.3 , if not, you must go to pear.php.net and install it, in my case, I needed to add the Socket.php to the PEAR library.

 

So the person that wrote this was not doing anything specific with osCommerce and I would suggest that the line with include/require/require_once "Mail.php" does not need to be there. And check that PEAR is installed on your server.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...