Jump to content

Archived

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

suhy

SMTP Contribution - www.oscommerce.com/community/contributions,901

Recommended Posts

Hi,

 

As I can see I'm not the only one haveing BIG troubles setting up SMTP Auth mail connection I opened a new thread for the contribution

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

 

as it seems the lates ... ans very neatly done ...

 

BUT, it doesn't work for me or any other SMTP contrib I tried to set up. I have numerous contribs installed, so I hope I'm not doing anything wrong !?

 

When I install the contrib and try to send an e-mail it says "E-mail sent OK", but no e-mail is delivered ...

 

Anyone with some pointers ? :'(

 

THANKS ! :thumbsup:

Share this post


Link to post
Share on other sites

The contribution always states "E-mail sent OK" regardless of what happens. This is mostly erroneous logic in the higher layer logic (tep_mail and checkout_process.php) not returning / checking for the results of an email transaction.

 

I had to snoop the network interface to figure out what was wrong. I tried to provide better / useful hint in the updated I posted; maybe I failed.

 

My prior update of the contribution is working against two different SMTP servers from a Linux based web server. I do not have a Windows based web server to test it against and I have not tried to test the the contribution in the sendmail mode.

 

Ben

 

Hi,

 

As I can see I'm not the only one haveing BIG troubles setting up SMTP Auth mail connection I opened a new thread for the contribution

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

 

as it seems the lates ... ans very neatly done ...

 

BUT, it doesn't work for me or any other SMTP contrib I tried to set up. I have numerous contribs installed, so I hope I'm not doing anything wrong !?

 

When I install the contrib and try to send an e-mail it says "E-mail sent OK", but no e-mail is delivered ...

 

Anyone with some pointers ? :'(

 

THANKS ! :thumbsup:

Share this post


Link to post
Share on other sites
The contribution always states "E-mail sent OK" regardless of what happens. This is mostly erroneous logic in the higher layer logic (tep_mail and checkout_process.php) not returning / checking for the results of an email transaction.

 

I had to snoop the network interface to figure out what was wrong. I tried to provide better / useful hint in the updated I posted; maybe I failed.

 

My prior update of the contribution is working against two different SMTP servers from a Linux based web server. I do not have a Windows based web server to test it against and I have not tried to test the the contribution in the sendmail mode.

 

Ben

 

Hi,

 

I'm also running it on Linux server, but with sendmail dissabled. When I'm using non AUTH server all is OK, but when I try to switch to a secure AUTH (TLS) server the emails are not getting out any more (except for the home server domain where the AUTH is not triggered I think ) ... Could there be some problem with AUTH ?

 

Regards,

Gregor

Share this post


Link to post
Share on other sites
I'm also running it on Linux server, but with sendmail dissabled. When I'm using non AUTH server all is OK, but when I try to switch to a secure AUTH (TLS) server the emails are not getting out any more (except for the home server domain where the AUTH is not triggered I think ) ... Could there be some problem with AUTH ?

 

Something weird is going on in the updated the class file:

 

$this->authenticated		= FALSE;
		$this->timeout			= 5;
		$this->status			= SMTP_STATUS_NOT_CONNECTED;
		$this->host			= "localhost";
		$this->port			= 25;
		$this->helo			= "localhost";
		$this->auth			= FALSE;
		$this->user			= "";
		$this->pass			= "";

 

Everything is mostly set to localhost with no passwords, what gives?

Share this post


Link to post
Share on other sites
Hi,

 

I'm also running it on Linux server, but with sendmail dissabled. When I'm using non AUTH server all is OK, but when I try to switch to a secure AUTH (TLS) server the emails are not getting out any more (except for the home server domain where the AUTH is not triggered I think ) ... Could there be some problem with AUTH ?

 

Regards,

Gregor

 

What version of the contribution are you using? I started the the August 3 2007 version posted by Carlos B. and had problems with it. I fixed the problems and posted the result 11 August 2007 version. If you are not using the lastest version you could be running into the same bug. The only way I discovered the error was to snoop the network interface and watch the SMTP exchange on my developement machine; this would not be pratical / possible on a live site due to network traffic and/or permissions.

Share this post


Link to post
Share on other sites
Something weird is going on in the updated the class file:

 

$this->authenticated		= FALSE;
		$this->timeout			= 5;
		$this->status			= SMTP_STATUS_NOT_CONNECTED;
		$this->host			= "localhost";
		$this->port			= 25;
		$this->helo			= "localhost";
		$this->auth			= FALSE;
		$this->user			= "";
		$this->pass			= "";

 

Everything is mostly set to localhost with no passwords, what gives?

 

The class constructor code now initializes the class variables to the documented default values instead of directly referencing the application specific configuration values. It sill works because the default values can be overwritten by the contents of a parameter array passed to the constructor (either directly when the class is instantiated or indirectly via the call to the connect method). The parameter array need only include the SMTP connection parameters that are different from the class defaults). The email class uses the parameter array feature to re-initialized almost all of the class variables by passing parameter array to the smtp::connect() method base on the application specific SMTP configuration values.

 

The code that overwrites the default values based on the parameter array immediately follows the code you listed above:

 

			//Override the default values with any passed parameters.
		foreach($params as $key => $value){

			$this->$key = $value;

		}

 

The overwrite code is a terrible hack which should be replace with dedicated passed parameters to the constructor and/or the connection method. A similar feature is used in the smtp::send() method to pass the email message itself. Another hacked-up piece of code that could use some TLC.

 

Ben

Share this post


Link to post
Share on other sites

Since I installed this grat contrib, the e-mails sent as "text/plain" always!!!

 

I've the last version installed.

 

Before this contribution, the mails has this code:

 

Content-Type: multipart/alternative; boundary="=_0fc40efc457d35ad59b8d78f9ffcbb48"

--=_0fc40efc457d35ad59b8d78f9ffcbb48

Content-Type: text/plain; charset=iso-8859-1

Content-Transfer-Encoding: 7bit

 

text message

 

--=_0fc40efc457d35ad59b8d78f9ffcbb48

Content-Type: text/html; charset=iso-8859-1

Content-Transfer-Encoding: quoted-printable

 

html message

 

 

Now, I have this code:

 

 

Content-Type: text/plain

--=_f7521ee896f48a28f13e8db67bbabaec

Content-Type: multipart/mixed; charset="iso-8859-1"

Content-Transfer-Encoding: 7bit

 

text code

 

--=_f7521ee896f48a28f13e8db67bbabaec

Content-Type: multipart/mixed; charset="iso-8859-1"

Content-Transfer-Encoding: quoted-printable

 

html message

 

Can somewone help me? I dont know where change this param

Share this post


Link to post
Share on other sites

I have just posted an updated to fix the bug I induced when I deleted erroneous logic as part of the 11 Aug 2007 contribution.

 

The 11 Aug 2007 release will not send out internally generated email (namely order confirmations; not a good thing!) when the module was configured for SMTP with an Internet message transfer agent like qmail which strictly enforces 822bis section 2.3. New logic now correctly replaces bare LF in the body of an email with CR/LF pairs. Bare LF in an email message are forbidden by 822bis.

 

If your are currently using the 11 Aug 2007 release of the SMTP contribution, upgrade to the 1 Oct 2007 version.

 

This release has been tested against qmail and sendmail message transfer agents. It was tested on a Linux 2.6 Apache 2.2.3 PHP 4.4.4-8 MySQL 5.0.32 server environment against Linux Iceweasel 2.0.0.3 and Window IE 6.0 browsers.

 

:'( Sorry!

Share this post


Link to post
Share on other sites

I just tried to install the latest version of this contrib and get the following errors when I try to send an email from the admin:

 

Warning: fsockopen(): unable to connect to smtp.heitmannsnuts.com:25 in /mnt/w0504/d40/s40/b0260e05/www/nuts2/nfoscomm/catalog/admin/includes/classes/class.smtp.php on line 93

 

Warning: Cannot modify header information - headers already sent by (output started at /mnt/w0504/d40/s40/b0260e05/www/nuts2/nfoscomm/catalog/admin/includes/classes/class.smtp.php:93) in /mnt/w0504/d40/s40/b0260e05/www/nuts2/nfoscomm/catalog/admin/includes/functions/general.php on line 18

 

 

Any ideas of what i've done wrong???

Share this post


Link to post
Share on other sites

The failure of the fsockopen call indicates that either the SMTP host name smtp.heitmannsnuts.com is incorrect or the port number 25 is wrong (i.e., the SMTP demon is not listening on that port number). Port number 25 is the default SMTP port; however, many hosting companies utilize a different port number (e.g, GoDaddy uses port 3535). Your host provider will tell you what port number they utilize if they do not support the default SMTP port.

 

Are you updating from a previous version of the contribution or is this the first time you have tried to install the SMTP support?

 

Are you hosted on a Linux box or a Windows box? I have tested the contribution on a Linux box, but I have not tested my revisions against a Windows based server.

 

Post your configuration settings (less any password information) here or email me via PM so I can look at what you have configured.

 

The second warning is a side effect of the first error.

 

Ben

Share this post


Link to post
Share on other sites

I have just installed the last version and all it's ok (i could send correctly a message from the Contact us form), but i don't receive any message... :-?

 

I know that's not too much info, but... Oh, yes... I'm on a unix host....

Share this post


Link to post
Share on other sites

The higher level modules (like tep_mail.php or contact_us.php ) that utilize the email class (modified by this contribution) do not check the status returned. The email is always reported as successfully sent to the user. I can understand why the higher level modules are coded this way. What are they going to do, report the error to the user? It doesn't make a lot of sense since the user can't do anything about it. Unfortunately, there is no logging / debug capability to turn on to easily figure out what is going wrong.

 

You have a problem with your configuration. I assume you downloaded this contribution because your web hosting company requires SMTP password authentication.

 

Your web hosting company should provide the following information: the SMTP server name (smtp.server.com in the example below) and port number (it might be port 25, but configure it anyway). Usually it doesn't matter what you use as the SMTP EHLO/HELO string; the hostname of your web site is fine. It is possible that your hosting company would specify what it must be, but this would be very unusual. The SMTP authentication username / password is the email username / password that you are required to use(i.e., it is your email address on the server). A typical configuration would look like:

 

E-Mail Transport Method smtp

E-Mail Linefeeds CRLF

Use MIME HTML When Sending Emails false

Verify E-Mail Addresses Through DNS false

Send E-Mails true

SMTP Server Host Address smtp.server.com

SMTP Server EHLO / HELO Name www.yourdomain.com

SMTP Server Port Number 25

SMTP Authentication Required true

SMTP Authentication Username you@yourdomain.com

SMTP Authentication Password xxxxxxx

 

It is possible that your web hosting company does not support SMTP password authentication behind the firewall on your web server and only requires it when you connect to the server from your desktop (to retrieve your email). Have you tried to configure a desktop email client to access your email? Try to do this as is can tell you something about the proper configuration parameters to access your SMTP server.

 

You can use a network sniffer like etherreal / wireshark to catch the protocol exchange if you have root privileges on the server. This would only be possible on your own development machine. On a web hosting company's server you can hack in some code to catch the SMTP exchange in the send_data() and get_data() routines in the class.smtp.php file. The SMTP exchange is all text based, so you can use the PHP var_dump routine to print the session to your web browser screen with something like the following:

 

var_dump( get_or_set_data, "<br>");

 

From the output it should be fairly obvious what is mis-configured.

 

Ben

Share this post


Link to post
Share on other sites

Ben,

 

I have tried out your "smtp through the authentication smtp server" posted on 6th Oct 2007 with osCommerce Online Merchant v2.2 RC1.

 

The code works well when I am updating customer orders.

 

If I use sendmail in the configuration,

order update email, send email and send newsletter all works except that the email sent has a header nobody@abbbbb.com and most of the time it is getting treated as Spam.

 

So used the SMTP auth based on your code:

order update email works perfect

but Send Email and Send Newsletters - there is no email sent.

 

Can you please advise.

 

thanks

DSANI

Share this post


Link to post
Share on other sites

Check the settings of the following parameters in admin -> My Store

 

Store Owner Customer Server

E-Mail Address customerservice@yourstore.com

E-Mail From customerservice@yourstore.com

 

The above parameters define the source addresses for the various emails originated by osCommerce. It shouldn't matter which email transport method (SMTP or sendmail) is used. I'm not certain what happens when one or both of the E-Mail parameters are not set. A quick search of the code did not turn up anything.

 

So used the SMTP auth based on your code:

order update email works perfect

but Send Email and Send Newsletters - there is no email sent.

 

Since one of the email sources are working, it sounds like your SMTP configuration parameters are correct; but frankly, I'm baffled by the problem you describe. I have not tried sending a newsletter yet, but I have tested both the "contact us" page and the admin -> tools -> send email page.

 

Are you on a Windows or Linux server? Do you know what email forwarding agent you are talking to?

Share this post


Link to post
Share on other sites

Ben,

 

Thanks a ton.

It was the setting Emailfrom:

earlier it was "Customer Service"<customerservice@yourstore.com>

Changed to : customerservice@yourstore.com

 

Now all is working with this new settings.

 

Could not figure out why this is happening. but it solved the problem.

 

thanks a lot

 

regards

 

 

Check the settings of the following parameters in admin -> My Store

 

Store Owner Customer Server

E-Mail Address customerservice@yourstore.com

E-Mail From customerservice@yourstore.com

 

The above parameters define the source addresses for the various emails originated by osCommerce. It shouldn't matter which email transport method (SMTP or sendmail) is used. I'm not certain what happens when one or both of the E-Mail parameters are not set. A quick search of the code did not turn up anything.

Since one of the email sources are working, it sounds like your SMTP configuration parameters are correct; but frankly, I'm baffled by the problem you describe. I have not tried sending a newsletter yet, but I have tested both the "contact us" page and the admin -> tools -> send email page.

 

Are you on a Windows or Linux server? Do you know what email forwarding agent you are talking to?

Share this post


Link to post
Share on other sites
Ben,

 

Thanks a ton.

It was the setting Emailfrom:

earlier it was "Customer Service"<customerservice@yourstore.com>

Changed to : customerservice@yourstore.com

 

Now all is working with this new settings.

 

Could not figure out why this is happening. but it solved the problem.

 

thanks a lot

 

regards

Hi!

I have a big problem everything works, beside this one when i should confirm order this happen:

Fatal error: Cannot redeclare class smtp in C:\wamp\www\catalog\includes\classes\class.smtp.php on line 12

someone have a qlue?

 

Regards Tony

Share this post


Link to post
Share on other sites
Hi!

I have a big problem everything works, beside this one when i should confirm order this happen:

Fatal error: Cannot redeclare class smtp in C:\wamp\www\catalog\includes\classes\class.smtp.php on line 12

someone have a qlue?

 

Regards Tony

The error means that somehow the SMTP class was included more than once in the code. This should not happen as the only place the class is included is in the email class. The email class is coded to only include the SMTP class once In the email.php file near line 523 :

 

include_once(DIR_WS_CLASSES . 'class.smtp.php');

Please describe what you do to confirm an order. Are you updating the status of an order on the admin -> customers ->orders page when the error occurs?

 

What versions of Windows, Apache, MySQL, and PHP make up your server environment? Did build up the WAMP environment yourself or did you download a pre-configured bundled environment?

Share this post


Link to post
Share on other sites
The error means that somehow the SMTP class was included more than once in the code. This should not happen as the only place the class is included is in the email class. The email class is coded to only include the SMTP class once In the email.php file near line 523 :

 

include_once(DIR_WS_CLASSES . 'class.smtp.php');

Please describe what you do to confirm an order. Are you updating the status of an order on the admin -> customers ->orders page when the error occurs?

 

What versions of Windows, Apache, MySQL, and PHP make up your server environment? Did build up the WAMP environment yourself or did you download a pre-configured bundled environment?

Hi!

I have vista, and wamp5 that includes Apache/2.2.4 (Win32) , PHP version :5.2.4 , MySQL version :5.0.45-community-nt and i downloaded it pre-configured only thing i changed by the order process is to take away the creditcard so its only way to pay i by billing.

I have tryed to find the problem so many hours so i'm soon mad :-)

 

/Tony

Share this post


Link to post
Share on other sites

Describe for the actions you take which cause the problem to occur. The customer places an order and then...

 

Are there any other contributions you added to the baseline ocCommerce distribution besides this one?

Share this post


Link to post
Share on other sites

I've posted an update to the contribution which includes a debug capability which is generally useful when dealing with SMTP configuration problems.

 

The debug capability is controlled by the variable $this->debug (near line 78) in the class.smtp.php file. When it is set to TRUE, the SMTP protocol exchange is dumped to the browser window. The debug output represents ASCII CR and LF characters as \r and \n. To use the capability, edit the class.smtp.php file in the /catalog/includes/classes directory and change the value from FALSE to TRUE. Utilize the "Contact Us" page to send an email message. When you select the "continue" button after constructing the email message the browser will display the SMTP protocol exchange messages ending with the following warning message:

 

Warning: Cannot modify header information - headers already sent by (output started at...

 

From the information displayed you should be able to resolve any SMTP configuration problems you are having. This capability is need because the higher level modules (like tep_mail.php or contact_us.php) that utilize the email class (modified by this contribution) do not check the status returned. The email is always reported as successfully sent to the user. Once you have determined the proper configuration parameters, edit the class.smtp.php file again and set the $this->debug variable to FALSE to disable this capability.

 

You can download the enhanced contribution from here.

Share this post


Link to post
Share on other sites

I just found and fixed the bug in email.php which caused the body of an email message to be double spaced. The bug caused every newline character sequence to be replaced with two newline character sequences when the email newline character was configured as the CRLF pair (which it must be when utilizing SMTP).

 

The updated SMTP Authentication contribution is available here.

 

The bug is not unique to the SMTP Authentication contribution and will occur with the baseline osCommerce email.php code whenever the email newline character is configured as CRLF.

 

The changes need to be made in the catalog/includes/classes/email.php and the catalog/admin/includes/classes/email.php files. In the add_text method (near line 149) your will find the following code:

 

$this->text = tep_convert_linefeeds(array("\r\n", "\n", "\r"), $this->lf, $text);

This code needs to be replace with the following code:

 

// Replace ASCII CR and LF characters with the configured LF character.
// Needs to be done in two passes to prevent doubling of line spacing.
$this->text = tep_convert_linefeeds(array("\r\n", "\n", "\r"), "xxCRLFxx", $text);
$this->text = tep_convert_linefeeds("xxCRLFxx", $this->lf, $this->text);

A similar change needs to be done in the add_html method (near line 160); however, in this case the original code looks like:

 

$this->html_text = tep_convert_linefeeds(array("\r\n", "\n", "\r"), $this->lf, $text);

and the modified code looks like:

 

 // Replace ASCII CR and LF characters with the configured LF character.
// Needs to be done in two passes to prevent doubling of line spacing.
$this->html_text = tep_convert_linefeeds(array("\r\n", "\n", "\r"), "xxCRLFxx", $text);
$this->html_text = tep_convert_linefeeds("xxCRLFxx", $this->lf, $this->html_text);

Ben

Share this post


Link to post
Share on other sites

Hi bpopelar .. or anyone else who can help me please!

 

re: Total SMTP Contribution to fix double spacing

 

Issue 1: not sure I should install this contrib. to solve my current problems

Problem:

* customers do not receive any emails from

- orders they placed

- requesting forgotten password

- emails sent to them from store

 

However the store owner does receive email order copy.

So it is only the customer who is not receiving any emails. What do I do please? Is this the correct contribution to install?

 

Issue 2: if this is the correct contribution to use, for step 2 in the instructions:

" 2. (MUST) Run the smtp_sql.sql file in your OScommerce database. Use PhpMyAdmin or any way to run SQL commands. "

 

...er ... I don't know how to run SQL commands at all. What do I do?? Please give me some pointers.

I tried going to to PHPAdmin to read the documentation but it really is worse than greek to me. Can someone please please help me with this???

 

thanks for your time,

Helena

Share this post


Link to post
Share on other sites

Hi Helena,

 

You stated that the store owner is receiving "email order copy". I assume you mean that the store owner is receiving email messages (as opposed to orders being posted to the database and you are looking at them via the admin side of the web site). If you are indeed receiving email, this means that basic email configuration is close to being correct; your problem may be nothing more than the email linefeed configuration parameter.

 

Tell me a little about your web site & server environment:

 

Are you hosted on a Windows or Linux based server?

 

Do you have your website email transport configured for SMTP or Sendmail?

 

What is your email linefeed parameter configured as (CRLF or LF)?

 

Are some of your customers receiving email or is everyone complaining about no emails? Do you know the domains of the customers who are not receiving email (e.g., hotmail, gmail, earthlink, ...)?

 

You can find the email configuration parameters in admin-> configuration -> email options.

 

You only need this contribution if your web hosting company requires SMTP Password Authenication to connect to their email servers. If you are receiving any emails from the website, then this contribution is not needed; however, there is some SMTP based debug capability built into the contribution which may be helpful in looking into your problem.

 

Provide answers to the above questions before I describe how to install the SQL updates to the database.

 

Ben

Share this post


Link to post
Share on other sites
Hi Helena,

 

You stated that the store owner is receiving "email order copy". I assume you mean that the store owner is receiving email messages (as opposed to orders being posted to the database and you are looking at them via the admin side of the web site). If you are indeed receiving email, this means that basic email configuration is close to being correct; your problem may be nothing more than the email linefeed configuration parameter.

 

Tell me a little about your web site & server environment:

 

Are you hosted on a Windows or Linux based server?

 

Do you have your website email transport configured for SMTP or Sendmail?

 

What is your email linefeed parameter configured as (CRLF or LF)?

 

Are some of your customers receiving email or is everyone complaining about no emails? Do you know the domains of the customers who are not receiving email (e.g., hotmail, gmail, earthlink, ...)?

 

You can find the email configuration parameters in admin-> configuration -> email options.

 

You only need this contribution if your web hosting company requires SMTP Password Authenication to connect to their email servers. If you are receiving any emails from the website, then this contribution is not needed; however, there is some SMTP based debug capability built into the contribution which may be helpful in looking into your problem.

 

Provide answers to the above questions before I describe how to install the SQL updates to the database.

 

Ben

 

Hello Ben! Phew! Thank you for replying my request :)

 

Email Order: Yes, the store owner is receiving email copies of orders (which can also be seen in the admin side).

There are no real customers yet. Just me pretending to be 'customers' (using different email accounts) and testing placing orders. The email domains (me as customers) are bigpond.net.au and shcredo.com .... And no emails are going to these 'customers'.

 

Email linefeed parameter: is LF (I have also tried CRLF and tested requesting forgotten password, sending emails-to-customer from store, and making purchases .. but 'customer' still does not get any emails)

 

My full current email options are set to:

E-Mail Transport Method: smtp

E-Mail Linefeeds: LF

Use MIME HTML When Sending Emails false

Verify E-Mail Addresses Through DNS false

Send E-Mails true

 

and I am hosted on Server OS: Linux 2.6.9-55.ELsmp

----------------------------------------------------------

Additiional update on further attempts to install the contribution:

I went to my PhpMyAdmin > selected my database > import > File to Import = (browsed to downloaded file: smtp_sql.sql >

Partial Import > (left as default values, ie) Tick (for 'Allow interrupt of import in case script detects it is close to time limit. This might be good way to import large files, however it can break transactions.') and 'Number of records(queries) to skip from start' = 0

> Format of imported file = (left the default values as is, ie) SQL compatibility mode = none

> Go

------------------

The result was that for the first 2 tries, it said something about wrong format ...

but on the final try (to reproduce the error msg so I could show you) .. it says "Import has been successfully finished, 6 queries executed."

 

oops! have I buggered things up now?? Do I need to/can I reverse this 'import' that I have inadvertently done???

 

Thanks for your time Ben :)

 

Helena

Share this post


Link to post
Share on other sites

×