AR_1986 Posted June 17, 2009 Share Posted June 17, 2009 Hi, everyone, im trying to configure my oscommerce website email but im having a nightmare doing it.for some reason my hosted streamline.net email address wont work when i use it on my site but every other email address will. The oscommerce admin is already configured to send emails but the only address it wont send to is the one i need to work (sales@mywebsite.co.uk). As a result i assumed it must be something at my hosting providers end stopping my emails from coming through to my outlook account from the website because hotmail accounts, yahoo accounts and even my virgin media account all work. I just needed to know what has to be be done to get emails on the contact us page to send to sales@mywebsite.co.uk when people click submit. I asked my host if they knew what the problem was and they said: - Thank you for your query To prevent spam being sent through our webservers, there are certain conditions that must be met before our SMTP servers will send the email. 1) Email must be sent to, or from, an email address hosted by Streamline.net. An email address hosted by Streamline.net is not the same as a domain name hosted by Streamline.net. If your domain's MX record points to another email provider, it will not count as being hosted by Streamline.net. 2) To stop misuse of your form by third parties the sendmail_from variable should be set to your Streamline.net hosted email address. While access to the php.ini file is restricted on our shared environment, you can set this variable using the ini_set() command, shown below. 3) A fifth parameter -f should be added to the sendmail function. This will set the name of the from email address. In its basic form, a simple sendmail script will look like this: ini_set("sendmail_from", " user@yourdomain.com "); mail($email_to, $email_subject, $email_message, $headers, '-fuser@yourdomain.com'); ?> Provided that you set the sendmail variable, before attempting to send the email. Specify the from address as a fifth parameter in the sendmail function, and the email is either to, or from, a Streamline.net hosted email address you should have no problems. Example This example will take the information from a feedback form, send it to you in an email message, then forward the customer to a "thank you for your comments" page. In this example we will use bobsdomain.co.uk as the domain name. There is a mailbox hosted with Streamline.net called bob@bobsdomain.co.uk. A simple feedback form First of all we need to create a feedback form that will receive the data. We will call this form feedback.html. In its most basic form, it can look like this: Email address: Name: Message: <br /> example feedback form Not the prettiest form, but it can be tidied up, and validation can be added at a later date. This form has three fields (email address, name and message) that users can fill in. Once the user click the Submit button, it will collect the information contained within the fields, tag the information as "email, name and message", then send the information to sendmail.php. The sendmail script Now we have a form that sends information to a script, we need to create a script to send the email. In this example, we will name the script sendmail.php as this is the address the our form is submitting the data to. In order to send an email, we need certain information (variables), so lets set them first. ini_set('sendmail_from', $email_from); $email_to = "bob@bobsdomain.co.uk"; $name =$_POST['name']; $email_from =$_POST['email']; $email_subject = "Feedback from website"; $comments = $_POST['message']; $headers = "From: $email_from .\n"; "Reply-To: $email_from .\n"; Now lets build the message of the email with the users name and comments. $message= "Name: ". $name . "\nComments: " . $comments; Finally, let's send the email. If the email is sent we will go to a thank you page, if there is an error we will display a brief message. $sent = mail($email_to, $email_subject, $message, $headers, '-f .$email_from'); if ($sent) { header( "Location: http://www.bobsdomain.co.uk/thankyou.html" ); } else { echo 'There has been an error sending your comments. Please try later.'; } ?> example sendmailscript form This script does not have any validation or error checking, so it is not recommended that you copy it directly to your website, however, it does show the basics of sending email from our webservers, and can be used as a framework for your own scripts. The only problem is i have no idea what that means, how to make a script, what to call it and where to put it for it to work. Im confused because the oscommerce store template comes with all its own files, like contact_us.php etc. would i have to change that? Is the script example above for people making their own site using php of would it still apply even if its a template im trying to customise. If anyone can help me, i'd be eternally grateful. Im a complete noob at php. The whole oscommerce store works apart from the email. Thankyou. Quote Link to comment https://forums.phpfreaks.com/topic/162562-please-help-new-to-php-and-stuck-with-email-script/ Share on other sites More sharing options...
AR_1986 Posted June 20, 2009 Author Share Posted June 20, 2009 can no one help? Im soo stuck. Has anyone with an oscommerce store experienced this problem? Quote Link to comment https://forums.phpfreaks.com/topic/162562-please-help-new-to-php-and-stuck-with-email-script/#findComment-860141 Share on other sites More sharing options...
darkjedig Posted June 22, 2009 Share Posted June 22, 2009 Hi there, I have registered just to give you some information. I, and thousands of other people are having the same problem with the contact forms and streamline. I have called them, created support tickets and tried six unique contact form scripts, including two based from their suggestions. Everytime i have not received anything in my inbox, and they refuse to help. The latest message I got was "I'm sorry, but we do not support, or provide help with scripts". What is so frustrating is the script I used was the one you posted above. (I got the same E-mail reply). So, the script they wrote and suggested does not work either, Im at the end of my tether with them . All I can say for sure, is that it seems to be malfunctioning on websites hosted on their newly updated servers. My older websites contact forms all work fine, yet the exact same form refuses to work on newly added domains. I believe that they have a problem with PHP5 and the (MAIL) function on their servers but they do not want to do anything about it. For me, my website says "mail sent successfully" with: if ($sent) { header( "Location: http://www.ctsafetybarriers.co.uk/success.html" ); } else { echo 'There has been an error sending your comments. Please try later.'; } however nothing is being received. My script is: <?php ini_set("sendmail_from", " root@ctsafetybarriers.co.uk "); $email_to = "sales@ctsafetybarriers.co.uk,ryan@sterlingdesignuk.com"; $name =$_POST['name']; $email_from =$_POST['email']; $email_subject = "Feedback from website"; $comments = $_POST['comments']; $headers = "From: $email_from .\n"; "Reply-To: $email_from .\n"; $message= "Name: ". $name . "\nComments: " . $comments; $sent = mail($email_to, $email_subject, $message, $headers, '-f .$email_from'); if ($sent) { header( "Location: http://www.ctsafetybarriers.co.uk/success.html" ); } else { echo 'There has been an error sending your comments. Please try later.'; } ?> Not RECEIVING ANYTHING! I know this is not much help but I wanted you to know its nothing to do with you or your script. Regards, -Jedi Quote Link to comment https://forums.phpfreaks.com/topic/162562-please-help-new-to-php-and-stuck-with-email-script/#findComment-861215 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.