Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

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


suhy

Recommended Posts

Also to give specific feed back on the code suggestions: Yes Ben

 

$send_params['headers'] = array_merge($this->headers, array("From: $from", "To: $to", "Subject: $subject", "Date: $date", "Reply-To: $from"));

 

Does insert the reply to email address into the header of the message.

 

Thanks again

On your last day only you will have to approve or disaprove of how your life has been.

Link to comment
Share on other sites

  • Replies 339
  • Created
  • Last Reply

I have been using this contribution and have begun having some intermittent problems with emails not being sent. I ran a test and got the following errors:

 

Warning: fsockopen() [function.fsockopen]: unable to connect to smtp.vzwmail.net:25 (Connection refused) in /home/supper5/public_html/os/includes/classes/class.smtp.php on line 102

 

Warning: fsockopen() [function.fsockopen]: unable to connect to smtp.vzwmail.net:25 (Connection refused) in /home/supper5/public_html/os/includes/classes/class.smtp.php on line 102

 

Warning: Cannot modify header information - headers already sent by (output started at /home/supper5/public_html/os/includes/classes/class.smtp.php:102) in /home/supper5/public_html/os/includes/functions/general.php on line 33

 

Note that I use Guest Account with the option that deletes the customer after the order is completed, soemaisl are not going out and the customer is not being deleted as a result. This seems to happen only once in a while. Other times everything works works just fine

 

Any ideas where to start to look?

 

Thanks,

 

Bruce

Link to comment
Share on other sites

  • 2 weeks later...
I have been using this contribution and have begun having some intermittent problems with emails not being sent. I ran a test and got the following errors:

 

Warning: fsockopen() [function.fsockopen]: unable to connect to smtp.vzwmail.net:25 (Connection refused) in /home/supper5/public_html/os/includes/classes/class.smtp.php on line 102

 

Warning: fsockopen() [function.fsockopen]: unable to connect to smtp.vzwmail.net:25 (Connection refused) in /home/supper5/public_html/os/includes/classes/class.smtp.php on line 102

 

Warning: Cannot modify header information - headers already sent by (output started at /home/supper5/public_html/os/includes/classes/class.smtp.php:102) in /home/supper5/public_html/os/includes/functions/general.php on line 33

 

Note that I use Guest Account with the option that deletes the customer after the order is completed, soemaisl are not going out and the customer is not being deleted as a result. This seems to happen only once in a while. Other times everything works works just fine

 

Any ideas where to start to look?

 

Thanks,

 

Bruce

Bruce,

 

Email servers can and do refuse connections when they are overloaded. You may need to talk to Verizon to see about using a different email server.

 

Currently, the SMTP class does not retry a failed connection. Such logic could be added, but your customer will be waiting a long time and the retries usually fail also.

 

Ben

Link to comment
Share on other sites

Bruce,

 

Email servers can and do refuse connections when they are overloaded. You may need to talk to Verizon to see about using a different email server.

 

Currently, the SMTP class does not retry a failed connection. Such logic could be added, but your customer will be waiting a long time and the retries usually fail also.

 

Ben

 

Thanks Ben, I am going to try to switch to another mail server at my hosting company to see if that works better. Glad I understand why it works sometimes and not others!

 

Bruce

Link to comment
Share on other sites

Thank you!!! Thank you!!! Thank you!!! Thank you!!! Thank you!!!

 

This was my problem too.

 

I could send e-mail from "Catalog" but not from "Admin" Section. The problem I found out to be in the Email From section it was

 

"xxxxxx" <[email protected]>

 

but changing it to (that is without the extra bells and whistles ... < > )

 

[email protected]

 

it worked perfectly.

 

Home someone finds this useful.

 

Just in case someone else misses this (like I did for some time), 'From' addresses in the form

 

"abc abc" <[email protected]>

 

will cause sending to fail if you are using Google's smtp server (maybe also with other smtp server - I haven't checked that). You need just plain

 

[email protected]

 

ps: thanks for the contrib!!

Link to comment
Share on other sites

Ben you are super duper!

I have a problem which is not really due to this contribution but related. I am using Google apps as the mail server. Now when someone sends an enquiry from the contact us page Google over writes the from address with the address being used by smtp authorization. The reply to address is not preserved! As far as I can tell from checking the contact_us.php page the harvested email address is listed as sender only (thus over written) there is no reply to address written to the message header.

Any suggestions on how to add a line to fix this?

I think that this would be of interest because I know that lots of people are adding this contribution to be able to use gmail and Google apps as their mail server.

Cheers

Christian

 

Guys since i have the same problem by using the google smtp server, is there another smtp that i can use and that u know is working correctly? i mean something like hotmail or stuff like that? i'm trying to make it works whit "fastweb" (i'm italian) but it's not going to work, so can u advice me another service to use like the google one?

 

thanks

Link to comment
Share on other sites

Guys since i have the same problem by using the google smtp server, is there another smtp that i can use and that u know is working correctly? i mean something like hotmail or stuff like that? i'm trying to make it works whit "fastweb" (i'm italian) but it's not going to work, so can u advice me another service to use like the google one?

 

thanks

Paolo,

 

The contribution works with just about any SMTP based email server. Most websites connect to their hosting company's email server to handle email message instead of connecting to an outside email server like Google. I know the contribution has been used to connect to Hotmail and Yahoo among other servers.

 

Many email providers, like Gmail, are requiring authenticated connects in order to fight spam and are replacing the From address with the authenticated account name. Anything they can do to fight spam is OK with me.

 

You can path the contribution to add a Reply-To header to all email addresses as I described earlier.

 

Why won't it work with Fastweb? What kind of errors are you getting with you try to use the contribution?

 

Ben

Link to comment
Share on other sites

i installed the contribution as instructed,however i can't send any emails now.

Warning: fsockopen() expects parameter 2 to be long, string given in D:\Domains\dakltd.co.uk\wwwroot\catalog\admin\includes\classes\class.smtp.php on line 102

Warning: Cannot modify header information - headers already sent by (output started at D:\Domains\dakltd.co.uk\wwwroot\catalog\admin\includes\classes\class.smtp.php:102) in D:\Domains\dakltd.co.uk\wwwroot\catalog\admin\includes\functions\general.php on line 22

any ideas?i tried turning on debugging but it is not writng any information even though permissions are correct.

the information i put in the sql file is as follows

INSERT INTO configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) VALUES ('SMTP Server Host Address', 'EMAIL_SMTP_HOST_SERVER', 'mail.cyberprog.com', 'The fully qualified host name of the SMTP server.', '12', '10', NULL, now());
INSERT INTO configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) VALUES ('SMTP Server EHLO / HELO Name', 'EMAIL_SMTP_HELO_SERVER', 'www.dakltd.co.uk', 'A name to send as part of the SMTP EHLO / HELO commands. The name is typically the hostname of the machine this web site runs on.', '12', '11', NULL, now());
INSERT INTO configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) VALUES ('SMTP Server Port Number', 'EMAIL_SMTP_PORT_SERVER', '25', 'The SMTP server port number. Port number 25 is typically used by default.', '12', '12', NULL, now());
INSERT INTO configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) VALUES ('SMTP Authentication Required', 'EMAIL_SMTP_ACTIVE_PASSWORD', 'true', 'Set to true when the SMTP Server requires password authentication.', '12', '13', 'tep_cfg_select_option(array(\'true\', \'false\'), ', now());
INSERT INTO configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) VALUES ('SMTP Authentication Username', 'EMAIL_SMTP_USERNAME', '[email protected]', 'The e-mail username sent to the server when SMTP password authentication is required.', '12', '14', NULL, now());
INSERT INTO configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) VALUES ('SMTP Authentication Password', 'EMAIL_SMTP_PASSWORD', '*******', 'The e-mail password sent to the server when SMTP password authentication is required.', '12', '15', NULL, now());

 

To actually add this to the database i renamed the smtp_sql.sql file to smtp_sql.txt and opened my database in access,and then imported it as a new table,it seemed to go ok,but could this be a problem?

Link to comment
Share on other sites

i installed the contribution as instructed,however i can't send any emails now.

Warning: fsockopen() expects parameter 2 to be long, string given in D:\Domains\dakltd.co.uk\wwwroot\catalog\admin\includes\classes\class.smtp.php on line 102

Warning: Cannot modify header information - headers already sent by (output started at D:\Domains\dakltd.co.uk\wwwroot\catalog\admin\includes\classes\class.smtp.php:102) in D:\Domains\dakltd.co.uk\wwwroot\catalog\admin\includes\functions\general.php on line 22

any ideas?i tried turning on debugging but it is not writng any information even though permissions are correct.

the information i put in the sql file is as follows

 

To actually add this to the database i renamed the smtp_sql.sql file to smtp_sql.txt and opened my database in access,and then imported it as a new table,it seemed to go ok,but could this be a problem?

 

The configuration parameters need to be added to the existing configuration table, not a new table.

 

If the configuration parameters are added to the existing configuration table, you should be able to go the the admin -> my store -> email options page to review / modify the settings.

 

Ben

Link to comment
Share on other sites

The configuration parameters need to be added to the existing configuration table, not a new table.

 

If the configuration parameters are added to the existing configuration table, you should be able to go the the admin -> my store -> email options page to review / modify the settings.

 

Ben

thanks for your help ben.

So basically i messed up on the database install part? :blush:

whats the easiest way to accomplish this properly?i know the instructions mention sql commands or phpmyadmin,but im not sure on how to proceed with either,if anyone has a relevant guide or information i'd appreciate it.

Link to comment
Share on other sites

thanks for your help ben.

So basically i messed up on the database install part? :blush:

whats the easiest way to accomplish this properly?i know the instructions mention sql commands or phpmyadmin,but im not sure on how to proceed with either,if anyone has a relevant guide or information i'd appreciate it.

I'm sure Access can handle SQL commands. I don't know Access well enough to tell you how. Try to Google an answer. I'm sure you will find something.

 

Ben

Link to comment
Share on other sites

Christian,

 

You could patch the email.php file to add a Reply-To header to each email. Near line 551 you will find the following code:

 

$send_params['headers'] = array_merge($this->headers, array("From: $from", "To: $to", "Subject: $subject", "Date: $date"));

Add a Reply-To header by modifying it to look like:

 

$send_params['headers'] = array_merge($this->headers, array("From: $from", "To: $to", "Subject: $subject", "Date: $date", "Reply-To: $from"));

 

Make sure to modify both copies of email.php

 

Try this and let me know if it works with Google Apps.

 

Ben

 

hi ben

i added those lines in the both email.php files, i tryed to send me a mail by the email sender tool in the admin of the oscommerce but nothing seems to change...what should i expect?

Link to comment
Share on other sites

hi ben

i added those lines in the both email.php files, i tryed to send me a mail by the email sender tool in the admin of the oscommerce but nothing seems to change...what should i expect?

Do any of the email functions work? Does the Contact Us page work? Does the customer receive an order confirmation email when they place an order?

 

Have you enabled the debug capability?

 

If nothing is working, send me your email configuration parameters via a private message so I can figure out what is wrong.

 

Ben

Link to comment
Share on other sites

Do any of the email functions work? Does the Contact Us page work? Does the customer receive an order confirmation email when they place an order?

 

Have you enabled the debug capability?

 

If nothing is working, send me your email configuration parameters via a private message so I can figure out what is wrong.

 

Ben

 

hi Ben,

first of all thanks for your interest,

all emails works perfectly, the order confirmation one, the password retreive one, the registration one,the Contact Us page works fine, but i don't see any difference in mail sent between when i didn't have the reply-to header script and now,

 

i mean what should happen in the emails?

Link to comment
Share on other sites

hi Ben,

first of all thanks for your interest,

all emails works perfectly, the order confirmation one, the password retreive one, the registration one,the Contact Us page works fine, but i don't see any difference in mail sent between when i didn't have the reply-to header script and now,

 

i mean what should happen in the emails?

Paolo,

 

When you receive an email message, it will contain a Reply-To header. Most email clients will display this header when you read a message and usually they will use the information in the Reply-To header as the destination when you reply to an email message.

 

The point of the patch was to preserve the original From email address (i.e., the customer's email address) when email servers like gmail replace original address with the authenticated SMTP connection account name (your ISP/website email address).

 

By working perfectly do you mean you receive the emails sent or are you just referring to the display of the "email sent successfully" page? The "email sent successfully" page is always displayed. The website can fail to send and email message and that page is still displayed (the higher level logic doesn't check the status returned by the email class.

 

Ben

Link to comment
Share on other sites

Paolo,

 

When you receive an email message, it will contain a Reply-To header. Most email clients will display this header when you read a message and usually they will use the information in the Reply-To header as the destination when you reply to an email message.

 

The point of the patch was to preserve the original From email address (i.e., the customer's email address) when email servers like gmail replace original address with the authenticated SMTP connection account name (your ISP/website email address).

 

By working perfectly do you mean you receive the emails sent or are you just referring to the display of the "email sent successfully" page? The "email sent successfully" page is always displayed. The website can fail to send and email message and that page is still displayed (the higher level logic doesn't check the status returned by the email class.

 

Ben

 

thanks Ben for the explanation,

 

then my script works fine, i can read the mail sender of the contact us page so i think is all working.

 

Paolo

Link to comment
Share on other sites

First off, thanks for this great contribution.

 

I seem to have an odd problem though, Emails threw the admin/tools/send email arn't seeming to work.

I've gotten it working for Contact Us, Password Recovery, Order Conformation I'm assuming that means account creation too.

 

I've tried turning on the admin/includes/classes/class.smtp.php debug, but can't find the file in /catalog or /catalog/admin o.O

Link to comment
Share on other sites

First off, thanks for this great contribution.

 

I seem to have an odd problem though, Emails threw the admin/tools/send email arn't seeming to work.

I've gotten it working for Contact Us, Password Recovery, Order Conformation I'm assuming that means account creation too.

 

I've tried turning on the admin/includes/classes/class.smtp.php debug, but can't find the file in /catalog or /catalog/admin o.O

 

Looks like it decided to work when I changed the from address to simply [email protected], Im using my site's mail server, and since things being sent from the catalog (password reset / order comformation) are able to be recieved as "Abc" <[email protected]> I'm kind of confused now

Link to comment
Share on other sites

Looks like it decided to work when I changed the from address to simply [email protected], Im using my site's mail server, and since things being sent from the catalog (password reset / order comformation) are able to be recieved as "Abc" <[email protected]> I'm kind of confused now

The store email address generated by the front side ( contact us / password reset ) is a combination of the Store Name and the Store Email address parameters defined in admin -> My Store. The parameters are used to form a cute email address like "Abc" <[email protected]>. The From email parameter is used by the back side admin function as the From: address and must be a bare internet style email address like "[email protected]" (without the quotes).

 

Ben

Link to comment
Share on other sites

ok in the end i got it all installed,i can send email via the admin panels send email option fine,i can send customer order updates fine..but here is the problem-

when a customer uses the contact us page the email arrives but is blank,there is no message.

The same thing happens when a customer registers at the store,an email arrives with the correct title etc but its blank.

here are the email settings:

E-Mail Address [email protected]

E-Mail From [email protected]

 

E-Mail Transport Method smtp

E-Mail Linefeeds CRLF

Use MIME HTML When Sending Emails true

Verify E-Mail Addresses Through DNS false

Send E-Mails true

SMTP Server Host Address mail.cyberprog.com

SMTP Server EHLO / HELO Name www.dakltd.co.uk

SMTP Server Port Number 25

SMTP Authentication Required true

SMTP Authentication Username [email protected]

SMTP Authentication Password *******

 

any ideas?i think and hope this is my last problem :rolleyes:

Link to comment
Share on other sites

ok in the end i got it all installed,i can send email via the admin panels send email option fine,i can send customer order updates fine..but here is the problem-

when a customer uses the contact us page the email arrives but is blank,there is no message.

The same thing happens when a customer registers at the store,an email arrives with the correct title etc but its blank.

here are the email settings:

E-Mail Address [email protected]

E-Mail From [email protected]

 

E-Mail Transport Method smtp

E-Mail Linefeeds CRLF

Use MIME HTML When Sending Emails true

Verify E-Mail Addresses Through DNS false

Send E-Mails true

SMTP Server Host Address mail.cyberprog.com

SMTP Server EHLO / HELO Name www.dakltd.co.uk

SMTP Server Port Number 25

SMTP Authentication Required true

SMTP Authentication Username [email protected]

SMTP Authentication Password *******

 

any ideas?i think and hope this is my last problem :rolleyes:

Andrew,

 

Have you tried setting the Use MIME HTML When Sending Email to false? Do you get the same results?

 

Have you turned on the debug? If so, send me the output in a PM.

 

Ben

Link to comment
Share on other sites

Andrew,

 

Have you tried setting the Use MIME HTML When Sending Email to false? Do you get the same results?

 

Have you turned on the debug? If so, send me the output in a PM.

 

Ben

hi ben,thanks for your reply.I have tried turning off MIME HTML the result was that the contact us form stopped sending emails completely,but the order update email and the manaul email option continued to work properly.

As for debug i have turned it on and will see what results i get.

Link to comment
Share on other sites

hi ben,thanks for your reply.I have tried turning off MIME HTML the result was that the contact us form stopped sending emails completely,but the order update email and the manaul email option continued to work properly.

As for debug i have turned it on and will see what results i get.

Andrew,

 

The good news (for me anyway) is you are receiving what is being sent...the body of the email message sent by the SMTP class was empty.

 

Now why is it empty...I need to look at the code and see if I can figure out how the body of the email could be empty.

 

Is there any chance that the very beginning of the email body was "CR.CR" or ".CR" where CR is the carriage return character? I actually think the code handles this case, but I have to double check.

 

Ben

Link to comment
Share on other sites

Andrew,

 

The good news (for me anyway) is you are receiving what is being sent...the body of the email message sent by the SMTP class was empty.

 

Now why is it empty...I need to look at the code and see if I can figure out how the body of the email could be empty.

 

Is there any chance that the very beginning of the email body was "CR.CR" or ".CR" where CR is the carriage return character? I actually think the code handles this case, but I have to double check.

 

Ben

not sure what you mean there ben,all i can tell you is that the test message i sent was a single sentance.what files are involved in the email process?is it possible there is a problem in one of them?i can check them against the stock versions.

Link to comment
Share on other sites

not sure what you mean there ben,all i can tell you is that the test message i sent was a single sentance.what files are involved in the email process?is it possible there is a problem in one of them?i can check them against the stock versions.

Andrew,

 

I looked at the code finally; it is correctly handling a "." on a line by itself found in the body of an email message.

 

I don't see anything in the email.php or class.smtp.php code that would cause the body of the email message to be lost or overwritten. The body of an email message will default to an empty string if the email::add_text method is not called or is called without a parameter.

 

Look in your code for a call to add_text and place a print statement just before the call to print out the passed parameter. Somewhere in the higher level logic, the body of your email is getting overwritten / lost.

 

Ben

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...