Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

errors when sending mails


Guest

Recommended Posts

I am new in php and in oscommerce, I installed all follow the instruction in the install file, create the tables by hand, and finally two days later, It works!!. But when oscommerce sends a mail the following warnings appear:

 

Warning: Could not execute mail delivery program in /www/cgi/catalog/admin/includes/classes/email.php on line 502

 

Warning: Cannot add header information - headers already sent by (output started at /www/cgi/catalog/admin/includes/classes/email.php:502) in /www/cgi/catalog/admin/includes/functions/general.php on line 18

 

 

My hosting service says that the sendmail program is located in usr/bin/sendmail

 

I do not know how to check if the oscommerce is using this program "sendmail" or where I can check & modify the path.

 

I tried looking in configuration.php, configure.php, email.php, mime.php, etc. but I really do not know how and where.

 

Any advice will be appreciate.

 

Thanks in advance

Link to comment
Share on other sites

I am new in php and in oscommerce, I installed all follow the instruction in the install file, create the tables by hand, and finally two days later, It works!!. But when oscommerce sends a mail the following warnings appear:

 

Warning: Could not execute mail delivery program in /www/cgi/catalog/admin/includes/classes/email.php on line 502

 

Warning: Cannot add header information - headers already sent by (output started at /www/cgi/catalog/admin/includes/classes/email.php:502) in /www/cgi/catalog/admin/includes/functions/general.php on line 18

 

 

My hosting service says that the sendmail program is located in usr/bin/sendmail

 

I do not know how to check if the oscommerce is using this program "sendmail" or where I can check & modify the path.

 

I tried looking in configuration.php, configure.php, email.php, mime.php, etc. but I really do not know how and where.

 

Any advice will be appreciate.

 

Thanks in advance

save this to your root as testsendmail.php

 

<?php
ini_set('sendmail_path', usr/bin/sendmail -t -i');
mail('[email protected]', 'Test', 'Is this working?', "From: [email protected]\nMIME-Version: 1.0");
?>

 

and change the e-mail addresses and run it to see if really works, if it works then the server has it setup right, if e-mails from your osCommerce system don't work then you have a config error somewhere, probably in your admin.

 

Hope this helps.

Best Regards

Link to comment
Share on other sites

I copied the code and executed it, but the following error appears:

 

Parse error: parse error in /www/cgi/testmail.php on line 3

 

Any idea??

 

Thanks

Link to comment
Share on other sites

Searching more info, in my hosting service I find an example of sendmail and it worked

 

here is the code:

 

<?php

include('Mail.php');

 

$recipients = '[email protected]';

 

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

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

$headers['Subject'] = 'Test message 1';

 

$body = 'Test message 1 with the body.';

 

$params['host'] = '127.0.0.1';

 

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

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

 

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

print "Sent Mail message to $recipients";

?>

 

I checked the mail.php included in the begining of the scrip and its simmilar to the one that comes with oscommerce.

 

O.K. the sendmail program is working, but I still have the problem with the oscommerce, where can I modify o reconfigure the path to use the parameters that worked?.

 

Any idea?? Thanks in advance

Link to comment
Share on other sites

I found the email.php in the following directory /admin/includes/classes/ and checking the whole code, the error ocurres at line 502:

 

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 {

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

}

}

 

at the begining of the code, there is a place where some variables are set, but I can not identify if there is a place for the path of the sendmail program

 

any ideas??

 

Best Regards....

Link to comment
Share on other sites

The example code you mentioned above doesn't really show that sendmail is working on your server. The PHP function mail() relies on sendmail to work, and it is the function that osC uses. The sample code you posted uses the function factory('smtp'...) from Mail.php (which might be something specific to the server). Not only is this not PHP's core mailing function, but it's using an smtp stream, rather than sendmail.

 

Sooo.. you can try setting up your email configuration to use smtp rather than sendmail and see if that makes a difference or figure out where the cut'n'paste of beardeddone's test code goofed up so you can try that test.

 

g'luck.

Link to comment
Share on other sites

O.k.

 

I changed the settings. In My Store, and in the e-mail options change from sendmail to smtp, sent a test mail and here is the result of that test:

 

Warning: Could not execute mail delivery program in /www/cgi/catalog/admin/includes/classes/email.php on line 501

 

Warning: Cannot add header information - headers already sent by (output started at /www/cgi/catalog/admin/includes/classes/email.php:501) in /www/cgi/catalog/admin/includes/functions/general.php on line 18

 

So, the error ocurrs one line before. Somewhere, the configuration for the mail is not working properly, neither smtp or sendmail are working.

 

Do anybody know in wich php file I can mannually change the configuration for the mail using the path that my hosting service provides?

 

/usr/sbin/sendmail

 

Thanks for the help.

Link to comment
Share on other sites

Try getting bearddone's test code to work:

 

<?php 
ini_set('sendmail_path', '/usr/sbin/sendmail -t -i');
mail('[email protected]', 'Test', 'Is this working?', "From: [email protected]\nMIME-Version: 1.0");
?>

 

I fixed the typo that was giving you the parse error. The first line of that code:

ini_set('sendmail_path', '/usr/sbin/sendmail -t -i'); is how you tell PHP what sendmail binary to use and where it's at, however /usr/sbin/sendmail is usually the default location.

 

Also, make sure you have your email addys in your admin config correct. The areas that need an email addy should *only* have an email addy, except for the section to send extra emails. In that section, follow the instructions it gives for specifying emails: name1 <[email protected]>, name2 <[email protected]>. Do not use that format in any of the other email boxes...

 

Hopefully that helps a bit.. G'luck.

 

*edit*:

Just noticed you gave a different path to sendmail on that last note.. I changed the above code bits to reflect that new path.

 

This was from the original text, and can be ignored: Now, considering the info you've given, make sure that the sendmail binary is at usr/bin/sendmail and *not* /usr/bin/sendmail .. I say this cause, unless your server has a specific osC setup, sendmail is probably not going to be in usr/bin/sendmail (note the lack of the beginning slash).

Link to comment
Share on other sites

O.k.

 

 

I tried again with the code, and double check the path, my hosting provider confirmed that the path is "/users/sbin/sendmail".

 

So the path in the code is o.k.

 

But when I run the php file a warning appears as follows:

 

Warning: Could not execute mail delivery program in /www/cgi/testmail.php on line 3

 

Any ideas??

 

Best Regards.....................

Link to comment
Share on other sites

O.k.

 

 

I tried again with the code, and double check the path, my hosting provider confirmed that the path is "/users/sbin/sendmail".

 

So the path in the code is o.k.

 

But when I run the php file a warning appears as follows:

 

Warning: Could not execute mail delivery program in /www/cgi/testmail.php on line 3

 

Any ideas??

 

Best Regards.....................

Is /www/cgi/ your root path, if not then testmail.php probably needs to be in your root, what ever that path name is.

Best Regards

Link to comment
Share on other sites

yes it is.

 

the oscommerce is also in that path:

 

/www/cgi/catalog/ etc....

 

/www/cgi/testmail.php

 

and the whole portal is working, the only thing that is not working is the email.

 

Regards

Link to comment
Share on other sites

yes it is.

 

the oscommerce is also in that path:

 

/www/cgi/catalog/ etc....

 

/www/cgi/testmail.php

 

and the whole portal is working, the only thing that is not working is the email.

 

Regards

Did you change the e-mail address to the one you use in the file testmail.php?

Best Regards

Link to comment
Share on other sites

  • 3 years later...

This thread did not seem to be resolved.

 

This is my quick fix for this problem.

 

/includes/functions/general.php line 1014

 

Change:-

 

// Instantiate a new mail object

$message = new email(array('X-Mailer: osCommerce Mailer'));

 

To this:-

 

// Instantiate a new mail object

$mailerreplyreturn = array(1 => 'X-Mailer: osCommerce Mailer', 'Return-Path: <[email protected]>', 'Reply-To: <[email protected]>');

 

$message = new email($mailerreplyreturn);

 

Where [email protected] is the address you send emals from in as set in Admin Configuration My Store

Link to comment
Share on other sites

Even better

 

// Instantiate a new mail object

 

$returnpath="Return-Path: <$from_email_address>";

$replyto="Reply-To: <$from_email_address>";

$mailerreplyreturn = array(1 => 'X-Mailer: osCommerce Mailer', $returnpath, $replyto);

 

It works with these settings at least:-

E-Mail Transport Method sendmail

E-Mail Linefeeds LF

Use MIME HTML When Sending Emails false

Verify E-Mail Addresses Through DNS false

Send E-Mails true

Link to comment
Share on other sites

  • 1 month later...

For those who stumble here again.

 

If you want to test your emails go here and use this contribution named: email testing script

http://www.oscommerce.com/community/contributions,1595

It was recommended on another thread. It is simple to use and when i tried it; i thought it was reliable.

 

:)

 

(my oscommerce won't send emails / errors / problems resulted in many hours research and trying of different solutions found on other osc forum threads about this problem, with no luck. In the end my host had to make changes for it to work!!)

 

:blink: :blink:

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...