This is a discussion on HTML Emails being sent as plain text or with source showing within the osCMax v1.7 Installation forums, part of the osCMax v1.7 Forums category; I have HTML Email enabled in admin and wysiwyg editor enabled. mainpage.php seems to work fine with wysiwyg editor ...
| |||||||
| Register | FAQ | Members List | Calendar | Mark Forums Read |
|
#1
| |||
| |||
| I have HTML Email enabled in admin and wysiwyg editor enabled. mainpage.php seems to work fine with wysiwyg editor and when I use the debug setting, I can see the HTML Email fine in the bottom screen.... When I preview the mail before sending it, it looks fine on my screen, but when I open my mail client.. outlook or web mail, the Email looks like the following, when it should be an image and some text... what am I missing? I've also tried this with email_test.php and gotten similar results. Im using SMTP to send Emails and HTML Emails from others look fine in my outlook client. This is a test of the email system<br><br><br><IMG alt=3D"" hspace=3D0 src= =3D"http://www.beadplace.se/bk/catalog/images/gv_100.gif" align=3Dbaseline = border=3D0> If anyone has any suggestions or help, it would be MUCH appreciated ! |
|
#2
| |||
| |||
| I forgot to mention that for the SMTP server to work I had to install a class.smtp.inc file (this is all from a contribution I downloaded at the oscommerce site) and change a few lines in mail.php The class.smtp.inc file is below Code: <?php
/***************************************
** Filename.......: class.smtp.inc
** Project........: SMTP Class
** Version........: 1.0.5
** Last Modified..: 21 December 2001
***************************************/
define('SMTP_STATUS_NOT_CONNECTED', 1, TRUE);
define('SMTP_STATUS_CONNECTED', 2, TRUE);
class smtp{
var $authenticated;
var $connection;
var $recipients;
var $headers;
var $timeout;
var $errors;
var $status;
var $body;
var $from;
var $host;
var $port;
var $helo;
var $auth;
var $user;
var $pass;
/***************************************
** Constructor function. Arguments:
** $params - An assoc array of parameters:
**
** host - The hostname of the smtp server Default: localhost
** port - The port the smtp server runs on Default: 25
** helo - What to send as the HELO command Default: localhost
** (typically the hostname of the
** machine this script runs on)
** auth - Whether to use basic authentication Default: FALSE
** user - Username for authentication Default: <blank>
** pass - Password for authentication Default: <blank>
** timeout - The timeout in seconds for the call Default: 5
** to fsockopen()
***************************************/
function smtp($params = array()){
if(!defined('CRLF'))
define('CRLF', "\r\n", TRUE);
$this->authenticated = FALSE;
$this->timeout = 5;
$this->status = SMTP_STATUS_NOT_CONNECTED;
$this->host = 'YOUR SMTP SERVER';
$this->port = 25;
$this->helo = '';
$this->auth = TRUE;
$this->user = 'YOUR EMAIL ADDRESS';
$this->pass = 'YOUR PASSWORD';
$this->errors = array();
foreach($params as $key => $value){
$this->$key = $value;
}
}
/***************************************
** Connect function. This will, when called
** statically, create a new smtp object,
** call the connect function (ie this function)
** and return it. When not called statically,
** it will connect to the server and send
** the HELO command.
***************************************/
function &connect($params = array()){
if(!isset($this->status)){
$obj = new smtp($params);
if($obj->connect()){
$obj->status = SMTP_STATUS_CONNECTED;
}
return $obj;
}else{
$this->connection = fsockopen($this->host, $this->port, $errno, $errstr, $this->timeout);
if(function_exists('socket_set_timeout')){
@socket_set_timeout($this->connection, 5, 0);
}
$greeting = $this->get_data();
if(is_resource($this->connection)){
return $this->auth ? $this->ehlo() : $this->helo();
}else{
$this->errors[] = 'Failed to connect to server: '.$errstr;
return FALSE;
}
}
}
/***************************************
** Function which handles sending the mail.
** Arguments:
** $params - Optional assoc array of parameters.
** Can contain:
** recipients - Indexed array of recipients
** from - The from address. (used in MAIL FROM:),
** this will be the return path
** headers - Indexed array of headers, one header per array entry
** body - The body of the email
** It can also contain any of the parameters from the connect()
** function
***************************************/
function send($params = array()){
foreach($params as $key => $value){
$this->set($key, $value);
}
if($this->is_connected()){
// Do we auth or not? Note the distinction between the auth variable and auth() function
if($this->auth AND !$this->authenticated){
if(!$this->auth())
return FALSE;
}
$this->mail($this->from);
if(is_array($this->recipients))
foreach($this->recipients as $value)
$this->rcpt($value);
else
$this->rcpt($this->recipients);
if(!$this->data())
return FALSE;
// Transparency
$headers = str_replace(CRLF.'.', CRLF.'..', trim(implode(CRLF, $this->headers)));
$body = str_replace(CRLF.'.', CRLF.'..', $this->body);
$body = $body[0] == '.' ? '.'.$body : $body;
$this->send_data($headers);
$this->send_data('');
$this->send_data($body);
$this->send_data('.');
$result = (substr(trim($this->get_data()), 0, 3) === '250');
//$this->rset();
return $result;
}else{
$this->errors[] = 'Not connected!';
return FALSE;
}
}
/***************************************
** Function to implement HELO cmd
***************************************/
function helo(){
if(is_resource($this->connection)
AND $this->send_data('HELO '.$this->helo)
AND substr(trim($error = $this->get_data()), 0, 3) === '250' ){
return TRUE;
}else{
$this->errors[] = 'HELO command failed, output: ' . trim(substr(trim($error),3));
return FALSE;
}
}
/***************************************
** Function to implement EHLO cmd
***************************************/
function ehlo(){
if(is_resource($this->connection)
AND $this->send_data('EHLO '.$this->helo)
AND substr(trim($error = $this->get_data()), 0, 3) === '250' ){
return TRUE;
}else{
$this->errors[] = 'EHLO command failed, output: ' . trim(substr(trim($error),3));
return FALSE;
}
}
/***************************************
** Function to implement RSET cmd
***************************************/
function rset(){
if(is_resource($this->connection)
AND $this->send_data('RSET')
AND substr(trim($error = $this->get_data()), 0, 3) === '250' ){
return TRUE;
}else{
$this->errors[] = 'RSET command failed, output: ' . trim(substr(trim($error),3));
return FALSE;
}
}
/***************************************
** Function to implement QUIT cmd
***************************************/
function quit(){
if(is_resource($this->connection)
AND $this->send_data('QUIT')
AND substr(trim($error = $this->get_data()), 0, 3) === '221' ){
fclose($this->connection);
$this->status = SMTP_STATUS_NOT_CONNECTED;
return TRUE;
}else{
$this->errors[] = 'QUIT command failed, output: ' . trim(substr(trim($error),3));
return FALSE;
}
}
/***************************************
** Function to implement AUTH cmd
***************************************/
function auth(){
if(is_resource($this->connection)
AND $this->send_data('AUTH LOGIN')
AND substr(trim($error = $this->get_data()), 0, 3) === '334'
AND $this->send_data(base64_encode($this->user)) // Send username
AND substr(trim($error = $this->get_data()),0,3) === '334'
AND $this->send_data(base64_encode($this->pass)) // Send password
AND substr(trim($error = $this->get_data()),0,3) === '235' ){
$this->authenticated = TRUE;
return TRUE;
}else{
$this->errors[] = 'AUTH command failed: ' . trim(substr(trim($error),3));
return FALSE;
}
}
/***************************************
** Function that handles the MAIL FROM: cmd
***************************************/
function mail($from){
if($this->is_connected()
AND $this->send_data('MAIL FROM:<'.$from.'>')
AND substr(trim($this->get_data()), 0, 2) === '250' ){
return TRUE;
}else
return FALSE;
}
/***************************************
** Function that handles the RCPT TO: cmd
***************************************/
function rcpt($to){
if($this->is_connected()
AND $this->send_data('RCPT TO:<'.$to.'>')
AND substr(trim($error = $this->get_data()), 0, 2) === '25' ){
return TRUE;
}else{
$this->errors[] = trim(substr(trim($error), 3));
return FALSE;
}
}
/***************************************
** Function that sends the DATA cmd
***************************************/
function data(){
if($this->is_connected()
AND $this->send_data('DATA')
AND substr(trim($error = $this->get_data()), 0, 3) === '354' ){
return TRUE;
}else{
$this->errors[] = trim(substr(trim($error), 3));
return FALSE;
}
}
/***************************************
** Function to determine if this object
** is connected to the server or not.
***************************************/
function is_connected(){
return (is_resource($this->connection) AND ($this->status === SMTP_STATUS_CONNECTED));
}
/***************************************
** Function to send a bit of data
***************************************/
function send_data($data){
if(is_resource($this->connection)){
return fwrite($this->connection, $data.CRLF, strlen($data)+2);
}else
return FALSE;
}
/***************************************
** Function to get data.
***************************************/
function &get_data(){
$return = '';
$line = '';
$loops = 0;
if(is_resource($this->connection)){
while((strpos($return, CRLF) === FALSE OR substr($line,3,1) !== ' ') AND $loops < 100){
$line = fgets($this->connection, 512);
$return .= $line;
$loops++;
}
return $return;
}else
return FALSE;
}
/***************************************
** Sets a variable
***************************************/
function set($var, $value){
$this->$var = $value;
return TRUE;
}
} // End of class
?>
The changes to the mail.php are listed beneath this line
Original Author: chen binghua
Modified By: Ray Knapp
XXXXXX-----XXXXX
Open and edit the class.smtp.inc
EDIT THE HOST, USERNAME, PASSWORD.
Upload the class.smtp.inc to catalog/includes/classes/ AND /admin/includes/classes/
XXXXXX-----XXXXX
Open and edit the email.php file in both catalog/includes/classes/
and /admin/includes/classes/
"EDIT THE HOST, HELO, USERNAME, PASSWORD."
FIND THE FOLLOWING LINE:
if (EMAIL_TRANSPORT == 'smtp') {
JUST BELOW IT REPLACE:
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));
WITH THE FOLLOWING:
// begin smtp authentication
include(DIR_WS_INCLUDES . '/classes/class.smtp.inc');
// The smtp server host/ip
$params['host'] = 'YOUR SMTP SERVER HERE';
// The smtp server port
$params['port'] = 25;
// What to use when sending the helo command. Typically, your domain/hostname $params['helo'] = 'YOUR DOMAIN/HOSTNAME HERE';
// Whether to use basic authentication or not
$params['auth'] = TRUE;
// Username for authentication
$params['user'] = 'YOUR USER NAME HERE';
// Password for authentication
$params['pass'] = 'YOUR PASSWORD HERE';
// The recipients (can be multiple)
$send_params['recipients'] = array("$to_addr");
$send_params['headers'] = array("From: $from", "To: $to_addr", "Subject: $subject");
// This is used as in the MAIL FROM: cmd
// It should end up as the Return-Path: header
$send_params['from'] = '';
// The body of the email $send_params['body'] = "$this->output";
is_object($smtp = smtp::connect($params)) AND $smtp->send($send_params);
// end smtp authentication
XXXXX-----XXXXX
WILL NOT WORK WITH EXTRA ORDER EMAILS
Go to admin
Select configuration / Send extra order emails to:
Make sure it is blank |
|
#3
| |||
| |||
| Im beginning to think this might have something to do with my SMTP server... if anyone has any ideas or suggestions, please let me know. I'd really like to be able to send HTML Emails! Until I get a response from here, I'll do some reading up on HTML Emails and maybe try another SMTP server program. |
|
#4
| |||
| |||
| well this morning I tried a different version of smtp software and got the exact same results, which makes me think it is a setting in my class.smtp.inc or mail.php... Im just not sure. If anyone has any idea what would make Emails sent as HTML appear with source code showing/plain text... HELP! An example of the results are in the first posting of this topic. |
|
#5
| ||||
| ||||
| In the osCMax admin under Configuration
__________________ Michael Sasek osCMax Developer osCMax Templates - Hundreds of premium quality templates. New designs every month! xShop for osCMax - Windows Based osCMax administration. Improved workflow, security, speed and convenience osCMax Hosting - From basic hosting to High Availability, Load Balanced arrays, the most experienced osCMax host. |
|
#6
| |||
| |||
| Thanks for the reply. Yes, I've got it set to true and when I compose an Email with the wyswyg editor, everything looks normal. I also tried the email_test.php contribution and even the html mail in that contribution shows text instead of html. Im not sure where to look next... |
|
#7
| |||
| |||
| I noticed that Outlook is reporting extra line breaks are being added to my HTML message. Could this have something to do with the HTML Emails not being formatted correctly? Which file actually handles the configuration and layout of the Email? is that mail.php ? |
|
#8
| |||
| |||
| This is the Email I receive when using the email_test.php contribution, which tests the functionality of (or lack thereof) osc/oscmax Email. I haven't seen what the readout should look like on other installations of OsC, but is there anyone using SMTP and sending HTML Emails without problem? What is missing or wrong with this Email... it looks like its sending a line before the Email header... if anyone has any help or suggestions, please chime in! --=_7ab5cc6d1dcef4480d4b6693a9b2ecbe Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit This email has been sent from the email class osCommerce uses. test --=_7ab5cc6d1dcef4480d4b6693a9b2ecbe Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable This email has been sent from the email class osCommerce uses.<br><br>test --=_7ab5cc6d1dcef4480d4b6693a9b2ecbe-- |
|
#9
| |||
| |||
| Just a follow up on this. There have been a few bug reports submitted regarding this issue and there is not really a good resolution. I have decided to continue using this particular installation without HTML Emails. Its not really a show stopper for me and I do know that it works fine if you are using sendmail and not SMTP. If anyone finds or hears of a solution, post it here ! Thanks. |
| Thread Tools | |
| |
| ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Reviews text not showing up | jazzdrive | osCommerce 2.2 Modification Help | 8 | 09-08-2005 07:40 AM |
| conflicting Text Characters html and php | anthon | osCommerce 2.2 Installation Help | 4 | 11-11-2004 10:35 PM |
| Reviews text not showing up | jazzdrive | osCMax v1.7 Discussion | 0 | 07-01-2004 12:20 PM |
| HTML in emails | Anonymous | osCMax v1.7 Discussion | 8 | 12-05-2003 09:09 AM |
| Product add but no image showing and HTML path wrong | rd42 | osCommerce 2.2 Installation Help | 8 | 06-12-2003 11:55 AM |