The same virus notification is received if the mail is sent by OC 1.4.8 as a standard order confirmation.
I guess that the problem is somewhere in the headers but I'm not an expert of SMTP.
If I send an HTML e-mail via my e-mail client (Mozilla) then it is not identified as a virus by the same ISP's spam filter, so there must be a minor bug in the Mail class of OC.
I guess that the problem is somewhere in the headers but I'm not an expert of SMTP.
If I send an HTML e-mail via my e-mail client (Mozilla) then it is not identified as a virus by the same ISP's spam filter, so there must be a minor bug in the Mail class of OC.
I have compared the two mail classes and identified the difference that solved the problem in my case. I found that a single line had to be removed from the Mail class (system/library/mail.php) of OC 1.4.8.
The line that need to be removed is line 145:
This is the last line of message composition, I guess it was inserted to close the message part.
Once I removed this line the HTML e-mail passed the virus scanner.
Do not hesitate to check if it solves the problem in your case as well and give a feedback.
The line that need to be removed is line 145:
Code: Select all
$message .= '--' . $boundary . '--' . $this->newline;
Once I removed this line the HTML e-mail passed the virus scanner.
Do not hesitate to check if it solves the problem in your case as well and give a feedback.
Well, my friends let me allow to correct my proposal. Do not delete the previously quoted line 145 from the Mail class but replace it with the following one:
Simple deletion would result ugly message display in Outlook and does not comply with MIME specification.
The only thing that was missing is an empty line before the closing boundary.
Any feedback is appreciated.
Code: Select all
$message .= $this->newline . '--' . $boundary . '--' . $this->newline;
The only thing that was missing is an empty line before the closing boundary.
Any feedback is appreciated.
Generally the whole mail class is buggy - as stated several times in the past.
Too many problems with different mail clients and systems.
Your solution may work inside and with your system, but the next user may have more troubles (or others).
Too many problems with different mail clients and systems.
Your solution may work inside and with your system, but the next user may have more troubles (or others).
Full Stack Web Developer :: Dedicated OpenCart Development & Support DACH Region
Contact for Custom Work / Fast Support.
if its a virus notifaction problem then its not oc's fault.
i'm using the mail system like it should work. the order emails sent out have both html and plain text sent in one email.
I have not really had any problems in a long time about the mail system.
i'm using the mail system like it should work. the order emails sent out have both html and plain text sent in one email.
I have not really had any problems in a long time about the mail system.
OpenCart®
Project Owner & Developer.
Daniel, I like OC, I think you did a really good job.
I just share my experience, which is the following: if you add an extra new line just before the closing boundary then virus notification disappears. The content of my test e-mails were exactly the same in both cases (with and without the new new line), so the virus scanner could not find other difference between them than the mentioned new line character. I can imagine that a more strict mail filter simply deletes the mail that does not contain an empty line before the closing boundary.
This is why I would be happy, if someone who had the problem with undelivered e-mails would also try to add the mentioned new line according to my previous post and check if it solves his/her problem.
I'm too lazy to read through the corresponding RFCs to check why the empty line is necessary but it seems there are systems, who require it.
I just share my experience, which is the following: if you add an extra new line just before the closing boundary then virus notification disappears. The content of my test e-mails were exactly the same in both cases (with and without the new new line), so the virus scanner could not find other difference between them than the mentioned new line character. I can imagine that a more strict mail filter simply deletes the mail that does not contain an empty line before the closing boundary.
This is why I would be happy, if someone who had the problem with undelivered e-mails would also try to add the mentioned new line according to my previous post and check if it solves his/her problem.
I'm too lazy to read through the corresponding RFCs to check why the empty line is necessary but it seems there are systems, who require it.
I was working with the modified Mail class without using attachments (I used the class outside of OC) without problems. Now, when I tried it with OC I found that the old problem with virus notification still exists.
Finally, I managed to make the provider's mail filter server silent. I have carried out the following changes:
1. Within the HTML alternative block of the message I have created a multipart/related block that holds both the HTML and the attachments (shop logo).
2. I have replaced the fixed attachment content type (application/octetstream) with an attachment extension dependent image/... content type.
I guess these changes may solve the problem of undelivered notification e-mails in some cases.
In order to check if it works for you simply replace the content of your system/library/mail.php file with the followings:
Note: I'm using OC 1.4.8 and the code above solved my problems at least for the moment.
Please, let me know if it helped.
Finally, I managed to make the provider's mail filter server silent. I have carried out the following changes:
1. Within the HTML alternative block of the message I have created a multipart/related block that holds both the HTML and the attachments (shop logo).
2. I have replaced the fixed attachment content type (application/octetstream) with an attachment extension dependent image/... content type.
I guess these changes may solve the problem of undelivered notification e-mails in some cases.
In order to check if it works for you simply replace the content of your system/library/mail.php file with the followings:
Code: Select all
<?php
final class Mail {
protected $to;
protected $from;
protected $sender;
protected $subject;
protected $text;
protected $html;
protected $attachments = array();
public $protocol = 'mail';
public $hostname;
public $username;
public $password;
public $port = 25;
public $timeout = 5;
public $newline = "\n";
public $crlf = "\r\n";
public $verp = FALSE;
public $parameter = '';
public function setTo($to) {
$this->to = $to;
}
public function setFrom($from) {
$this->from = $from;
}
public function addheader($header, $value) {
$this->headers[$header] = $value;
}
public function setSender($sender) {
$this->sender = $sender;
}
public function setSubject($subject) {
$this->subject = $subject;
}
public function setText($text) {
$this->text = $text;
}
public function setHtml($html) {
$this->html = $html;
}
public function addAttachment($file, $filename = '') {
if (!$filename) {
$filename = basename($file);
}
$this->attachments[] = array(
'filename' => $filename,
'file' => $file
);
}
private function getContentTypeByExtension($file_name) {
$ctype = 'application/octetstream';
$fext = pathinfo($file_name, PATHINFO_EXTENSION);
if (strcasecmp($fext, 'png')==0) {
$ctype = 'image/png; name="' . basename($file_name) . '"';
} else if(strcasecmp($fext, 'jpg')==0) {
$ctype = 'image/jpeg; name="' . basename($file_name) . '"';
} else if(strcasecmp($fext, 'gif')==0) {
$ctype = 'image/gif; name="' . basename($file_name) . '"';
} else if(strcasecmp($fext, 'tif')==0 || strcasecmp($fext, 'tiff')==0) {
$ctype = 'image/tiff; name="' . basename($file_name) . '"';
}
return $ctype;
}
private function importAttachments($att_boundary) {
$message = '';
foreach ($this->attachments as $attachment) {
if (file_exists($attachment['file'])) {
$handle = fopen($attachment['file'], 'r');
$content = fread($handle, filesize($attachment['file']));
fclose($handle);
$message .= '--' . $att_boundary . $this->newline;
$message .= 'Content-Type: '. $this->getContentTypeByExtension($attachment['file']) . $this->newline;
$message .= 'Content-Transfer-Encoding: base64' . $this->newline;
$message .= 'Content-Disposition: attachment; filename="' . basename($attachment['filename']) . '"' . $this->newline;
$message .= 'Content-ID: <' . basename($attachment['filename']) . '>' . $this->newline . $this->newline;
$message .= chunk_split(base64_encode($content));
} else {
print 'Attachment not found: ' . $attachment['file'];
}
}
return $message;
}
public function send() {
if (!$this->to) {
exit('Error: E-Mail to required!');
}
if (!$this->from) {
exit('Error: E-Mail from required!');
}
if (!$this->sender) {
exit('Error: E-Mail sender required!');
}
if (!$this->subject) {
exit('Error: E-Mail subject required!');
}
if ((!$this->text) && (!$this->html)) {
exit('Error: E-Mail message required!');
}
if (is_array($this->to)) {
$to = implode(',', $this->to);
} else {
$to = $this->to;
}
$boundary = '----=_NextPart_' . md5(time());
$header = '';
if ($this->protocol != 'mail') {
$header .= 'To: ' . $to . $this->newline;
$header .= 'Subject: ' . $this->subject . $this->newline;
}
$header .= 'From: ' . $this->sender . ' <' . $this->from . '>' . $this->newline;
$header .= 'Reply-To: ' . $this->sender . '<' . $this->from . '>' . $this->newline;
$header .= 'Return-Path: ' . $this->from . $this->newline;
$header .= 'X-Mailer: PHP/' . phpversion() . $this->newline;
$header .= 'MIME-Version: 1.0' . $this->newline;
$header .= 'Content-Type: multipart/mixed; boundary="' . $boundary . '"' . $this->newline;
if (!$this->html) {
$message = '--' . $boundary . $this->newline;
$message .= 'Content-Type: text/plain; charset="utf-8"' . $this->newline;
$message .= 'Content-Transfer-Encoding: 8bit' . $this->newline . $this->newline;
$message .= $this->text . $this->newline;
$message .= $this->importAttachments($boundary);
} else {
$message = '--' . $boundary . $this->newline;
$message .= 'Content-Type: multipart/alternative; boundary="' . $boundary . '_alt"' . $this->newline . $this->newline;
$message .= '--' . $boundary . '_alt' . $this->newline;
$message .= 'Content-Type: text/plain; charset="utf-8"' . $this->newline;
$message .= 'Content-Transfer-Encoding: 8bit' . $this->newline;
if ($this->text) {
$message .= $this->text . $this->newline;
} else {
$message .= 'This is a HTML email and your email client software does not support HTML email!' . $this->newline;
}
$message .= '--' . $boundary . '_alt' . $this->newline;
$message .= 'Content-Type: multipart/related; boundary="' . $boundary . '_rel"' . $this->newline . $this->newline;
$message .= '--' . $boundary . '_rel' . $this->newline;
$message .= 'Content-Type: text/html; charset="utf-8"' . $this->newline;
$message .= 'Content-Transfer-Encoding: 8bit' . $this->newline . $this->newline;
$message .= $this->html . $this->newline;
$message .= $this->importAttachments($boundary . '_rel');
$message .= '--' . $boundary . '_rel--' . $this->newline . $this->newline;
$message .= '--' . $boundary . '_alt--' . $this->newline . $this->newline;
}
$message .= '--' . $boundary . '--' . $this->newline;
if ($this->protocol == 'mail') {
ini_set('sendmail_from', $this->from);
if ($this->parameter) {
mail($to, $this->subject, $message, $header, $this->parameter);
} else {
mail($to, $this->subject, $message, $header);
}
} elseif ($this->protocol == 'smtp') {
$handle = fsockopen($this->hostname, $this->port, $errno, $errstr, $this->timeout);
if (!$handle) {
error_log('Error: ' . $errstr . ' (' . $errno . ')');
} else {
if (substr(PHP_OS, 0, 3) != 'WIN') {
socket_set_timeout($handle, $this->timeout, 0);
}
while ($line = fgets($handle, 515)) {
if (substr($line, 3, 1) == ' ') {
break;
}
}
if (substr($this->hostname, 0, 3) == 'tls') {
fputs($handle, 'STARTTLS' . $this->crlf);
while ($line = fgets($handle, 515)) {
$reply .= $line;
if (substr($line, 3, 1) == ' ') {
break;
}
}
if (substr($reply, 0, 3) != 220) {
error_log('Error: STARTTLS not accepted from server!');
}
}
if (!empty($this->username) && !empty($this->password)) {
fputs($handle, 'EHLO ' . getenv('SERVER_NAME') . $this->crlf);
$reply = '';
while ($line = fgets($handle, 515)) {
$reply .= $line;
if (substr($line, 3, 1) == ' ') {
break;
}
}
if (substr($reply, 0, 3) != 250) {
error_log('Error: EHLO not accepted from server!');
}
fputs($handle, 'AUTH LOGIN' . $this->crlf);
$reply = '';
while ($line = fgets($handle, 515)) {
$reply .= $line;
if (substr($line, 3, 1) == ' ') {
break;
}
}
if (substr($reply, 0, 3) != 334) {
error_log('Error: AUTH LOGIN not accepted from server!');
}
fputs($handle, base64_encode($this->username) . $this->crlf);
$reply = '';
while ($line = fgets($handle, 515)) {
$reply .= $line;
if (substr($line, 3, 1) == ' ') {
break;
}
}
if (substr($reply, 0, 3) != 334) {
error_log('Error: Username not accepted from server!');
}
fputs($handle, base64_encode($this->password) . $this->crlf);
$reply = '';
while ($line = fgets($handle, 515)) {
$reply .= $line;
if (substr($line, 3, 1) == ' ') {
break;
}
}
if (substr($reply, 0, 3) != 235) {
error_log('Error: Password not accepted from server!');
}
} else {
fputs($handle, 'HELO ' . getenv('SERVER_NAME') . $this->crlf);
$reply = '';
while ($line = fgets($handle, 515)) {
$reply .= $line;
if (substr($line, 3, 1) == ' ') {
break;
}
}
if (substr($reply, 0, 3) != 250) {
error_log('Error: HELO not accepted from server!');
}
}
if ($this->verp) {
fputs($handle, 'MAIL FROM: <' . $this->from . '>XVERP' . $this->crlf);
} else {
fputs($handle, 'MAIL FROM: <' . $this->from . '>' . $this->crlf);
}
$reply = '';
while ($line = fgets($handle, 515)) {
$reply .= $line;
if (substr($line, 3, 1) == ' ') {
break;
}
}
if (substr($reply, 0, 3) != 250) {
error_log('Error: MAIL FROM not accepted from server!');
}
if (!is_array($this->to)) {
fputs($handle, 'RCPT TO: <' . $this->to . '>' . $this->crlf);
$reply = '';
while ($line = fgets($handle, 515)) {
$reply .= $line;
if (substr($line, 3, 1) == ' ') {
break;
}
}
if ((substr($reply, 0, 3) != 250) && (substr($reply, 0, 3) != 251)) {
error_log('Error: RCPT TO not accepted from server!');
}
} else {
foreach ($this->to as $recipient) {
fputs($handle, 'RCPT TO: <' . $recipient . '>' . $this->crlf);
$reply = '';
while ($line = fgets($handle, 515)) {
$reply .= $line;
if (substr($line, 3, 1) == ' ') {
break;
}
}
if ((substr($reply, 0, 3) != 250) && (substr($reply, 0, 3) != 251)) {
error_log('Error: RCPT TO not accepted from server!');
}
}
}
fputs($handle, 'DATA' . $this->crlf);
$reply = '';
while ($line = fgets($handle, 515)) {
$reply .= $line;
if (substr($line, 3, 1) == ' ') {
break;
}
}
if (substr($reply, 0, 3) != 354) {
error_log('Error: DATA not accepted from server!');
}
fputs($handle, $header . $message . $this->crlf);
fputs($handle, '.' . $this->crlf);
$reply = '';
while ($line = fgets($handle, 515)) {
$reply .= $line;
if (substr($line, 3, 1) == ' ') {
break;
}
}
if (substr($reply, 0, 3) != 250) {
error_log('Error: DATA not accepted from server!');
}
fputs($handle, 'QUIT' . $this->crlf);
$reply = '';
while ($line = fgets($handle, 515)) {
$reply .= $line;
if (substr($line, 3, 1) == ' ') {
break;
}
}
if (substr($reply, 0, 3) != 221) {
error_log('Error: QUIT not accepted from server!');
}
fclose($handle);
}
}
}
}
?>
Please, let me know if it helped.
ERROR:
Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /customers/------.it/-------.it/httpd.www/system/library/mail.php:406) in /customers/--------.it/---------.it/httpd.www/system/library/session.php on line 11
Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /customers/------.it/-------.it/httpd.www/system/library/mail.php:406) in /customers/--------.it/---------.it/httpd.www/system/library/session.php on line 11
Than you made an error while copying the posted code.
The script is exactly 406 lines long - the error code means there is something wrong.
Check your error log, there you should see the corrct line and error message.
The script is exactly 406 lines long - the error code means there is something wrong.
Check your error log, there you should see the corrct line and error message.
Full Stack Web Developer :: Dedicated OpenCart Development & Support DACH Region
Contact for Custom Work / Fast Support.
I am getting this error can you help me out...I am using open cart 1.5.2
Notice: Error: RCPT TO not accepted from server! in /home/www/xxxxxxxxxx/system/library/mail.php on line 308
Notice: Error: RCPT TO not accepted from server! in /home/www/xxxxxxxxxx/system/library/mail.php on line 308
iqubalsingh wrote:I am getting this error can you help me out...I am using open cart 1.5.2
Notice: Error: RCPT TO not accepted from server! in /home/www/xxxxxxxxxx/system/library/mail.php on line 308
i'm having the same issue as well. anyone got any idea what is this regarding? i've try searching online but to avail.
jasperlee88 wrote:iqubalsingh wrote:I am getting this error can you help me out...I am using open cart 1.5.2
Notice: Error: RCPT TO not accepted from server! in /home/www/xxxxxxxxxx/system/library/mail.php on line 308
i'm having the same issue as well. anyone got any idea what is this regarding? i've try searching online but to avail.
okie. issue solve. i just change the store setting email(rather then using gmail) to my domain email and that settle it.
Who is online
Users browsing this forum: No registered users and 33 guests