Page 1 of 1

Mails not properly encoded[SOLVED]

Posted: Sat Sep 25, 2010 4:34 pm
by maccadon
I sent the mail from Opencart thru Google Apps.
In the Gmail client i can read the emails but in the email clients Mozilla Thunderbird and Postbox these emails come in Blank.
I asked the tech depart. of Postbox and they said the Emails sent aren't of the RFC822 standard.
Now instead of using a email client i have to open google mail just for the received order mails.

I'm concerned that my customers receive the same blank email so i would like to know if anybody has a sollution?

See the bugtracker http://www.opencart.com/index.php?route ... &bug_id=70

Tried it on:
Opencart 1.4.8. / 1.4.8b / 1.4.9 / 1.4.9.1
Extensions used
Mymodule (simple HTML)
Homeslider
Global mega options

For sending the mail i use smtp mailer
SSL://smtp.gmail.com
Port 465

Re: Mails not properly encoded

Posted: Sat Sep 25, 2010 5:50 pm
by i2Paq
Always mention version of your OpenCart!

Re: Mails not properly encoded

Posted: Thu Oct 07, 2010 11:42 pm
by maccadon
Does anybody have any idea?

I can read the mail in my google apps gmail account but in my email program (thunderbird/postbox) it appears blank.
This is what i get when i check the source.

Code: Select all

Return-Path: <info@*.nl>
Received: from www.*.nl (da-004.xl-is.net [89.31.97.221])
        by mx.google.com with ESMTPS id z55sm3632026eeh.3.2010.10.07.08.33.58
        (version=SSLv3 cipher=RC4-MD5);
        Thu, 07 Oct 2010 08:33:59 -0700 (PDT)
Message-ID: <4cade867.cf7d0e0a.0148.ffff9ea7@mx.google.com>
Date: Thu, 07 Oct 2010 08:33:59 -0700 (PDT)
To: info@*.nl
Subject: Vraag rene
From: rene <info@*.nl>
Reply-To: rene<rene@*.nl>
Return-Path: rene@*.nl
X-Mailer: PHP/5.2.11
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="----=_NextPart_318711e6a403b44adbcfc262011ff55b"
------=_NextPart_318711e6a403b44adbcfc262011ff55b
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit

This is a test using the smtp protocol with ssl://smtp.gmail.com on port 465
------=_NextPart_318711e6a403b44adbcfc262011ff55b--


Re: Mails not properly encoded

Posted: Fri Oct 15, 2010 6:56 pm
by peter72
I am not sure, but I had a similar problem with OpenCart plus Google Apps and fetchmail.

Code: Select all

reading message user@domain.tld@pop.gmail.com: 1 of 1 (123456789 octets) fetchmail: incorrect header line found while scanning headers not flushed
In my case I started to work well when I added $this->newline at the end of the header.
I just checked it in Mozilla Thunderbird, and also works correctly.

file: system/library/mail.php
line: 102 (version OC 1.4.9.1)

before

Code: Select all

$header .= 'Content-Type: multipart/mixed; boundary="' . $boundary . '"' . $this->newline; 
after

Code: Select all

$header .= 'Content-Type: multipart/mixed; boundary="' . $boundary . '"' . $this->newline;
$header .= $this->newline; 

Re: Mails not properly encoded

Posted: Fri Oct 15, 2010 10:25 pm
by maccadon
Wow Peter,

I have to try it further but it looks like it works!!
Thank you very much!

Do you have a paypal acount? Then i can buy you a beer.

Re: Mails not properly encoded

Posted: Wed Oct 20, 2010 8:16 pm
by peter72
Hi maccadon,
maccadon wrote:I have to try it further but it looks like it works!! Thank you very much!
Do you have a paypal acount? Then i can buy you a beer.
No problem.
I have a PayPal account. But no. Thank you for the beer. :-)
I also use the accumulated knowledge on this forum.

Greetings,
Peter

Re: Mails not properly encoded

Posted: Fri Oct 22, 2010 2:31 am
by dnoble
Thx Peter ... that helped

Re: Mails not properly encoded[SOLVED]

Posted: Sun May 29, 2011 12:47 am
by speedingorange
I have just upgraded to 1.4.9.4 from 1.4.9.3 and am now getting issues with the subject of the email showing as a question mark. Any ideas what the fix is?

It displays fine in gmail / google apps just not in thunderbird

Or if this could be a related issue?
This only happens with order related emails, enquiries etc all come through fine.

Cheers
James

Re: Mails not properly encoded[SOLVED]

Posted: Thu Jun 30, 2011 4:21 pm
by JeffBeck35
Hello All,

I have a problem.

(version OC 1.4.9.4)

My email program mozilla thunderbird and postbox these emails come in "Blank." ( Just text - without image )

http://imageshack.us/photo/my-images/801/20670739.png/

Waiting for valuable answers.

Thanks.
Jeff

Re: Mails not properly encoded[SOLVED]

Posted: Fri Jul 01, 2011 6:27 am
by JeffBeck35
Yes Yes Yes!

I Solved Problem! :)

vuuuuuvvvvvvvv! O0

Solved :

1- OC Version 1.4.9.4

2 - Mail Php Files; ( system/library/mail.php )

16. - 17.

Code: Select all

	public $newline = "\n";
	public $crlf = "\r\n";
37. - 38.

Code: Select all

  public function setSubject($subject) {
      $this->subject = '=?UTF-8?B?' . base64_encode($subject) . '?=';
   }
105.106.

Code: Select all

		$header .= 'Content-Transfer-Encoding: 8bit' . $this->newline;		
		$header .= $this->newline; 
Must be...

And my Mail.php file :

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 = html_entity_decode($sender);
	}

  public function setSubject($subject) {
      $this->subject = '=?UTF-8?B?' . base64_encode($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
		);
	}

	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 .= 'Date: ' . date("D, d M Y H:i:s O") . $this->newline;
		//$header .= 'From: "' . $this->sender . '" <' . $this->from . '>' . $this->newline;
		//$header .= 'From: ' . $this->sender . '<' . $this->from . '>' . $this->newline;
		$header .= 'From: ' . '=?UTF-8?B?'.base64_encode($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;
		$header .= 'Content-Transfer-Encoding: 8bit' . $this->newline;		
		$header .= $this->newline; 

		if (!$this->html) {
			$message  = '--' . $boundary . $this->newline;
			$message .= '' . $this->newline;
			$message .= '' . $this->newline . $this->newline;
			$message .= $this->text . $this->newline;
		} 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->newline;
			}

			$message .= '--' . $boundary . '_alt' . $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 .= '--' . $boundary . '_alt--' . $this->newline;
		}

foreach ($this->attachments as $attachment) { 
         if (file_exists($attachment['file'])) {
            $handle = fopen($attachment['file'], 'r');
            $content = fread($handle, filesize($attachment['file']));
      
            fclose($handle); 
      
            $message .= '--' . $boundary . $this->newline;
            $message .= 'Content-Type: application/octetstream' . $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));
         }
      }

		$message .= '--' . $boundary . '--' . $this->newline;

		if ($this->protocol == 'mail') {
			ini_set('sendmail_from', $this->from);

			if ($this->parameter) {
				mail($to, '=?UTF-8?B?'.base64_encode($this->subject).'?=', $message, $header, $this->parameter);
			} else {
				mail($to, '=?UTF-8?B?'.base64_encode($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);
			}
		}
	}
}
?>
3 - Contact Form : ( admin/controller/sale/contact.php )

91. Deleted

Code: Select all

$message = str_replace($value, 'cid:' . basename($filename), $message);
110. Before

Code: Select all

$mail->addAttachment($attachment['path'], $attachment['filename']);
110. After & New

Code: Select all

$mail->addAttachment($attachment['filename'], $attachment['filename']);
All Right!

Perfect Worked!

Hotmail, Gmail, Yahoo, AOL, Outlook, Outlook Express, Mozilla Thunderbird, Windows Mail, mail.mywebsite.com/mail

Working with all of them all...

Thanks All,

Re: Mails not properly encoded[SOLVED]

Posted: Fri Jul 29, 2011 2:20 pm
by steppen321
Hi JeffBeck35,


do You had any luck with OC 1.4.9.5 ?

Neither default, nor Your provided mail.php doesn't work properly in 1.4.9.5.

For example:

New customer receives a welcome email to Yahoo mailbox, but an email with order information (on order confirmation) never comes to Yahoo mailbox.

Re: Mails not properly encoded[SOLVED]

Posted: Wed Oct 19, 2011 7:24 am
by uncleremus
I was having a similar issue in 1.5.0. What worked for me was to add a second new line after the "Content-Transfer-Encoding:" header.

Line 114 of system/library/mail.php

Orginal: $message .= 'Content-Transfer-Encoding: 8bit' . $this->newline;
Edited: $message .= 'Content-Transfer-Encoding: 8bit' . $this->newline . $this->newline;

Re: Mails not properly encoded[SOLVED]

Posted: Thu Nov 03, 2011 4:16 am
by deejunit
Strangely enough none of these tips worked for me. My problem was that all the e-mails sent to Yahoo were delivered, but yet did not seem to contain anything - they were just blank.

As I said, tried all of the tips above, in addition to various other (older) threads:
http://forum.opencart.com/viewtopic.php?t=13581
http://forum.opencart.com/viewtopic.php ... rder+blank

My version of opencart is 1.5.1.2.

Finally I managed to solve my problem by changing email protocol from smtp to email. Previously I was using SMTP and gmail smtp to send my e-mails, ssl://smtp.gmail.com:465 as I some how figured this would be safer when it comes to spam filters (?) since my store is located on a shared host. Changing this back to email - and everything works again. Emails in yahoo are delivered correctly, this time with content.

If anyone has a trick to make the emails non-blank when sent to yahoo using gmail smtp, please let me know how you did it :)

Re: Mails not properly encoded[SOLVED]

Posted: Sun Jan 15, 2012 9:52 am
by webstudent1
Expiriences the same problem in the latest versions 1.5.1.3
Change around line 104-> to add the send line here in the mail.php

Code: Select all

		$header .= 'Content-Type: multipart/related; boundary="' . $boundary . '"' . $this->newline;
		$header .= $this->newline;
It worked again.

And gmail is 100% ok

Re: Mails not properly encoded[SOLVED]

Posted: Mon Feb 13, 2012 7:04 am
by canadian
JeffBeck35 wrote:Yes Yes Yes!

I Solved Problem! :)

vuuuuuvvvvvvvv! O0

Solved :

1- OC Version 1.4.9.4

2 - Mail Php Files; ( system/library/mail.php )

16. - 17.

Code: Select all

	public $newline = "\n";
	public $crlf = "\r\n";
37. - 38.

Code: Select all

  public function setSubject($subject) {
      $this->subject = '=?UTF-8?B?' . base64_encode($subject) . '?=';
   }
105.106.

Code: Select all

		$header .= 'Content-Transfer-Encoding: 8bit' . $this->newline;		
		$header .= $this->newline; 
Must be...

And my Mail.php file :

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 = html_entity_decode($sender);
	}

  public function setSubject($subject) {
      $this->subject = '=?UTF-8?B?' . base64_encode($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
		);
	}

	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 .= 'Date: ' . date("D, d M Y H:i:s O") . $this->newline;
		//$header .= 'From: "' . $this->sender . '" <' . $this->from . '>' . $this->newline;
		//$header .= 'From: ' . $this->sender . '<' . $this->from . '>' . $this->newline;
		$header .= 'From: ' . '=?UTF-8?B?'.base64_encode($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;
		$header .= 'Content-Transfer-Encoding: 8bit' . $this->newline;		
		$header .= $this->newline; 

		if (!$this->html) {
			$message  = '--' . $boundary . $this->newline;
			$message .= '' . $this->newline;
			$message .= '' . $this->newline . $this->newline;
			$message .= $this->text . $this->newline;
		} 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->newline;
			}

			$message .= '--' . $boundary . '_alt' . $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 .= '--' . $boundary . '_alt--' . $this->newline;
		}

foreach ($this->attachments as $attachment) { 
         if (file_exists($attachment['file'])) {
            $handle = fopen($attachment['file'], 'r');
            $content = fread($handle, filesize($attachment['file']));
      
            fclose($handle); 
      
            $message .= '--' . $boundary . $this->newline;
            $message .= 'Content-Type: application/octetstream' . $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));
         }
      }

		$message .= '--' . $boundary . '--' . $this->newline;

		if ($this->protocol == 'mail') {
			ini_set('sendmail_from', $this->from);

			if ($this->parameter) {
				mail($to, '=?UTF-8?B?'.base64_encode($this->subject).'?=', $message, $header, $this->parameter);
			} else {
				mail($to, '=?UTF-8?B?'.base64_encode($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);
			}
		}
	}
}
?>
3 - Contact Form : ( admin/controller/sale/contact.php )

91. Deleted

Code: Select all

$message = str_replace($value, 'cid:' . basename($filename), $message);
110. Before

Code: Select all

$mail->addAttachment($attachment['path'], $attachment['filename']);
110. After & New

Code: Select all

$mail->addAttachment($attachment['filename'], $attachment['filename']);
All Right!

Perfect Worked!

Hotmail, Gmail, Yahoo, AOL, Outlook, Outlook Express, Mozilla Thunderbird, Windows Mail, mail.mywebsite.com/mail

Working with all of them all...

Thanks All,
This is Brilliant!!! Thanks for posting this. You just made my day MUCH better!

Re: Mails not properly encoded[SOLVED]

Posted: Tue Apr 17, 2012 2:16 am
by iqubalsingh
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

Re: Mails not properly encoded[SOLVED]

Posted: Wed Jun 27, 2012 5:16 am
by waldz
Did not display body of email in Yahoo and Gmail and on iOS 5, instead only subject is displayed.

Peter72's solution worked for me.

I use version: 1.5.1.3

Thankyou :)

Re: Mails not properly encoded[SOLVED]

Posted: Mon Jul 08, 2013 12:46 am
by dlew
Thanks Peter!
Worked with 1.5.1.3