Post by zeevy » Fri Jul 31, 2009 3:31 pm

hello i am getting emails like this

------=_NextPart_d92de908f556e1c6293f0f397be56264
Content-Type: multipart/alternative; boundary="----=_NextPart_d92de908f556e1c6293f0f397be56264_alt"

------=_NextPart_d92de908f556e1c6293f0f397be56264_alt
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: base64
VGhpcyBpcyBhIEhUTUwgZW1haWwgYW5kIHlvdXIgZW1haWwgY2xpZW50IHNvZnR3YXJlIGRvZXMg
bm90IHN1cHBvcnQgSFRNTCBlbWFpbCE=
------=_NextPart_d92de908f556e1c6293f0f397be56264_alt
Content-Type: text/html; charset="utf-8"
Content-Transfer-Encoding: base64

PGh0bWwgZGlyPSJsdHIiIGxhbmc9ImVuIj4KPGhlYWQ+Cjx0aXRsZT5zZGZkczwvdGl0bGU+Cjxt
ZXRhIGh0dHAtZXF1aXY9IkNvbnRlbnQtVHlwZSIgY29udGVudD0idGV4dC9odG1sOyBjaGFyc2V0
PVVURi04Ij4KPC9oZWFkPgo8Ym9keT48cD5mc2RmZHNmPC9wPjwvYm9keT4KPC9odG1sPgo=
------=_NextPart_d92de908f556e1c6293f0f397be56264_alt--

any solutions

please

gv

New member

Posts

Joined
Tue Jul 21, 2009 8:08 pm

Post by Daniel » Fri Jul 31, 2009 6:05 pm

really?

is there any extra infromation you think you might want to give us?

such as what email client you use?

OpenCart®
Project Owner & Developer.


User avatar
Administrator

Posts

Joined
Fri Nov 03, 2006 6:57 pm

Post by zeevy » Fri Jul 31, 2009 7:45 pm

Daniel wrote:really?

is there any extra infromation you think you might want to give us?

such as what email client you use?
No email clients i am using gmail with browser firefox.

and i altered mail.php, and class name Mail => eMail ( also in other files ) to work with PEAR mail package,


Please let me know if any thing wrong with the bellow code.
and please tell me how to send newletter with this code

<?php
final class eMail {
protected $protocol = 'smtp';
protected $smtp_host = '';
protected $smtp_username = '';
protected $smtp_password = '';
protected $smtp_port = '465';
protected $smtp_timeout = 5;
protected $to;
protected $from;
protected $sender;
protected $subject;
protected $text;
protected $html;
protected $attachments = array();

public function __construct($protocol = 'mail', $smtp_host = '', $smtp_username = '', $smtp_password = '', $smtp_port = '465', $smtp_timeout = '5') {
$this->protocol = $protocol;
$this->smtp_host = $smtp_host;
$this->smtp_username = $smtp_username;
$this->smtp_password = $smtp_password;
$this->smtp_port = $smtp_port;
$this->smtp_timeout = $smtp_timeout;
}

public function setTo($to) {
$this->to = $to;
}

public function setFrom($from) {
$this->from = $from;
}

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($attachments) {
$this->attachments[] = $attachments;
}

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(rand());

if (strtoupper(substr(PHP_OS, 0, 3) == 'WIN')) {
$eol = "\r\n";
} elseif (strtoupper(substr(PHP_OS, 0, 3) == 'MAC')) {
$eol = "\r";
} else {
$eol = "\n";
}

$headers = 'From: ' . $this->sender . '<' . $this->from . '>' . $eol;
$headers .= 'Reply-To: ' . $this->sender . '<' . $this->from . '>' . $eol;
$headers .= 'X-Mailer: PHP/' . phpversion() . $eol;
$headers .= 'MIME-Version: 1.0' . $eol;
$headers .= 'Content-Type: multipart/mixed; boundary="' . $boundary . '"' . $eol;

if (!$this->html) {
$message = '--' . $boundary . $eol;
$message .= 'Content-Type: text/plain; charset="utf-8"' . $eol;
$message .= 'Content-Transfer-Encoding: base64' . $eol . $eol;
$message .= chunk_split(base64_encode($this->text));
} else {
$message = '--' . $boundary . $eol;
$message .= 'Content-Type: multipart/alternative; boundary="' . $boundary . '_alt"' . $eol . $eol;
$message .= '--' . $boundary . '_alt' . $eol;
$message .= 'Content-Type: text/plain; charset="utf-8"' . $eol;
$message .= 'Content-Transfer-Encoding: base64' . $eol;

if ($this->text) {
$message .= chunk_split(base64_encode($this->text));
} else {
$message .= chunk_split(base64_encode('This is a HTML email and your email client software does not support HTML email!'));
}

$message .= '--' . $boundary . '_alt' . $eol;
$message .= 'Content-Type: text/html; charset="utf-8"' . $eol;
$message .= 'Content-Transfer-Encoding: base64' . $eol . $eol;
$message .= chunk_split(base64_encode($this->html));
$message .= '--' . $boundary . '_alt--' . $eol;
}


foreach ($this->attachments as $attachment) {
$filename = basename($attachment);
$handle = fopen($attachment, 'r');
$content = fread($handle, filesize($attachment));

fclose($handle);

$message .= '--' . $boundary . $eol;
$message .= 'Content-Type: application/octetstream' . $eol;
$message .= 'Content-Transfer-Encoding: base64' . $eol;
$message .= 'Content-Disposition: attachment; filename="' . $filename . '"' . $eol;
$message .= 'Content-ID: <' . $filename . '>' . $eol . $eol;
$message .= chunk_split(base64_encode($content));
}

require_once "Mail.php";


$headers = array ('From' => $this->from, 'To' => $to, 'Subject' => $this->subject);
$smtp = Mail::factory('smtp', array ('host' => $this->smtp_host, 'port' => $this->smtp_port, 'auth' => true, 'username' => $this->smtp_username, 'password' => $this->smtp_password));
$mail = $smtp->send($to, $headers, $message);

}
}
?>

New member

Posts

Joined
Tue Jul 21, 2009 8:08 pm

Post by zeevy » Mon Aug 03, 2009 1:40 pm

Daniel wrote:really?

is there any extra infromation you think you might want to give us?

such as what email client you use?

May be a silly question but i don't understart why we need to encode email content with base64 while any one can easily and decode it.


thanks

gv

New member

Posts

Joined
Tue Jul 21, 2009 8:08 pm

Post by Daniel » Mon Aug 10, 2009 7:18 pm

I thnk its to stop people trying to hack it.

i'm looking over the pear class now to see if it can give me any clues how to fix the mail class.

I don;t want to use a 3rd party one becayuse the codign is normally not good.

OpenCart®
Project Owner & Developer.


User avatar
Administrator

Posts

Joined
Fri Nov 03, 2006 6:57 pm

Post by zeevy » Mon Aug 10, 2009 7:33 pm

Thanks,
even we don't want to hack it ( opencart is just great ), but we need thinks to workout.

New member

Posts

Joined
Tue Jul 21, 2009 8:08 pm

Post by jfima » Wed Nov 11, 2009 1:41 pm

gmail , outlook, the bat
have this problem

i'm found the best implementation of mail class in PEAR Mail
http://pear.php.net/package/Mail/docs

Newbie

Posts

Joined
Wed Nov 11, 2009 12:55 pm

Post by jfima » Wed Nov 11, 2009 3:14 pm

you can try this method:

Code: Select all

public $eol = "\n";
gmail ok
outlook ok

Newbie

Posts

Joined
Wed Nov 11, 2009 12:55 pm

Post by Daniel » Fri Nov 20, 2009 4:34 am

Can someone with this problem please pm me there ftp detaisl so I can fix the mail problem.

OpenCart®
Project Owner & Developer.


User avatar
Administrator

Posts

Joined
Fri Nov 03, 2006 6:57 pm
Who is online

Users browsing this forum: No registered users and 8 guests