Post by BigBrother » Sun Jun 28, 2009 7:17 pm

I have a question. I would always send a text newsletter. Not as Html Mail. Under admin / controller / customer / Mail.php can I find the code. How do I change the code so that I always in the newsletter can send as text-Mail.

Thx 4 help.

Greetz
BigBrother

New member

Posts

Joined
Fri Jun 19, 2009 12:14 am

Post by readyman » Mon Jun 29, 2009 6:46 pm

Go to admin/controller/customer/mail.php and view the code in that file.

I hope this helps.

http://www.alreadymade.com
Follow me on twitter.com/alreadymade


User avatar
Global Moderator

Posts

Joined
Wed May 20, 2009 5:16 am
Location - Sydney

Post by BigBrother » Mon Jun 29, 2009 8:43 pm

Hello redyman,
thx for your answer.
Yes, I have found the Php- code. But I do not know how I must change the code. Can someone help me?

admin/controller/customer/mail.php at line 37

Code: Select all

if ($emails) {
				$message  = '<html dir="ltr" lang="en">' . "\n";
				$message .= '<head>' . "\n";
				$message .= '<title>' . $this->request->post['subject'] . '</title>' . "\n";
				$message .= '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">' . "\n";
				$message .= '</head>' . "\n";
				$message .= '<body>' . htmlspecialchars_decode($this->request->post['message']) . '</body>' . "\n";
				$message .= '</html>' . "\n";
				

foreach ($emails as $email) {
					$mail = new Mail();	
					$mail->setTo($email);
					$mail->setFrom($this->config->get('config_email'));
	    			$mail->setSender($this->config->get('config_store'));
	    			$mail->setSubject($this->request->post['subject']);
					$mail->setHtml($message);
	    			$mail->send();
				}
			}
I have change the code:

Code: Select all

if ($emails) {
				$message .= $this->request->post['subject']  . "\n";
				$message .= htmlspecialchars_decode($this->request->post['message']) . "\n";
				
				

foreach ($emails as $email) {
					$mail = new Mail();	
					$mail->setTo($email);
					$mail->setFrom($this->config->get('config_email'));
	    			$mail->setSender($this->config->get('config_store'));
	    			$mail->setSubject($this->request->post['subject']);
					$mail->settext($message);
	    			$mail->send();
				}
			}
Is this code right?

Thanks for the help.

New member

Posts

Joined
Fri Jun 19, 2009 12:14 am

Post by readyman » Mon Jun 29, 2009 10:05 pm

Sorry, I assumed you knew php or just wanted to know where the files involved were... umm... this *should* work, I haven't tested it, but it looks ok.
The main problem here is that the content will still be html, even if you send it out as text... eg. if you bold some text, then you'll get the html tags as well. eg. <b>Your text</b>
You'd have to get rid of the visual editor as well... look at admin/view/template/customer/mail.tpl and replace all contents with this.

Code: Select all

<?php if ($error_warning) { ?>
<div class="warning"><?php echo $error_warning; ?></div>
<?php } ?>
<?php if ($success) { ?>
<div class="success"><?php echo $success; ?></div>
<?php } ?>
<div class="heading">
  <h1><?php echo $heading_title; ?></h1>
  <div class="buttons"><a onclick="$('#form').submit();" class="button"><span class="button_left button_send"></span><span class="button_middle"><?php echo $button_send; ?></span><span class="button_right"></span></a><a onclick="location='<?php echo $cancel; ?>';" class="button"><span class="button_left button_cancel"></span><span class="button_middle"><?php echo $button_cancel; ?></span><span class="button_right"></span></a></div>
</div>
<div class="tabs"><a tab="#tab_general"><?php echo $tab_general; ?></a></div>
<form action="<?php echo $action; ?>" method="post" enctype="multipart/form-data" id="form">
  <div id="tab_general" class="page">
    <table class="form">
      <tr>
        <td width="25%"><?php echo $entry_to; ?></td>
        <td><select name="to">
            <?php if ($to == 'newsletter') { ?>
            <option value="newsletter" selected="selected"><?php echo $text_newsletter; ?></option>
            <?php } else { ?>
            <option value="newsletter"><?php echo $text_newsletter; ?></option>
            <?php } ?>
            <?php if ($to == 'customer') { ?>
            <option value="customer" selected="selected"><?php echo $text_customer; ?></option>
            <?php } else { ?>
            <option value="customer"><?php echo $text_customer; ?></option>
            <?php } ?>
            <?php foreach ($customers as $customer) { ?>
            <?php if ($customer['customer_id'] == $to) { ?>
            <option value="<?php echo $customer['customer_id']; ?>" selected="selected"><?php echo $customer['name']; ?></option>
            <?php } else { ?>
            <option value="<?php echo $customer['customer_id']; ?>"><?php echo $customer['name']; ?></option>
            <?php } ?>
            <?php } ?>
          </select></td>
      </tr>
      <tr>
        <td><span class="required">*</span> <?php echo $entry_subject; ?></td>
        <td><input name="subject" value="<?php echo $subject; ?>" />
          <br />
          <?php if ($error_subject) { ?>
          <span class="error"><?php echo $error_subject; ?></span>
          <?php } ?></td>
      </tr>
      <tr>
        <td><span class="required">*</span> <?php echo $entry_message; ?></td>
        <td><textarea name="message" id="message" cols="65" rows="10"><?php echo $message; ?></textarea>
          <?php if ($error_message) { ?>
          <span class="error"><?php echo $error_message; ?></span>
          <?php } ?></td>
      </tr>
    </table>
  </div>
</form>
<script type="text/javascript"><!--
$.tabs('.tabs a'); 
//--></script>
Hope this works.

http://www.alreadymade.com
Follow me on twitter.com/alreadymade


User avatar
Global Moderator

Posts

Joined
Wed May 20, 2009 5:16 am
Location - Sydney

Post by BigBrother » Tue Jun 30, 2009 1:39 am

I have an error, if i use the code.
:-(
The mail was sending but i get this notice!

Code: Select all

Notice: Undefined variable: message in /homepages/xx/xxxx/htdocs/xxx/admin/controller/customer/mail.php on line 58

Warning: Cannot modify header information - headers already sent by (output started at /homepages/xx/xxxx/htdocs/xxx/admin/controller/customer/mail.php:58) in /homepages/xx/xxx7/htdocs/xxx/system/engine/controller.php on line 23
admin/controller/customer/mail.php Line 58:

Code: Select all

            $message .= $this->request->post['subject']  . "\n";
system/engine/controller.php Line 23

Code: Select all

header('Location: ' . html_entity_decode($url));

New member

Posts

Joined
Fri Jun 19, 2009 12:14 am

Post by BigBrother » Tue Jun 30, 2009 4:37 pm

I'm so blind!!!

Here is the instructions for sending a text-mail as newsletter.

Go to admin/view/template/customer/mail.tpl

Search

Code: Select all

if ($emails) {
            $message  = '<html dir="ltr" lang="en">' . "\n";
            $message .= '<head>' . "\n";
            $message .= '<title>' . $this->request->post['subject'] . '</title>' . "\n";
            $message .= '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">' . "\n";
            $message .= '</head>' . "\n";
            $message .= '<body>' . htmlspecialchars_decode($this->request->post['message']) . '</body>' . "\n";
            $message .= '</html>' . "\n";
            

foreach ($emails as $email) {
               $mail = new Mail();   
               $mail->setTo($email);
               $mail->setFrom($this->config->get('config_email'));
                $mail->setSender($this->config->get('config_store'));
                $mail->setSubject($this->request->post['subject']);
               $mail->setHtml($message);
                $mail->send();
            }
         }
Replace :

Code: Select all

if ($emails) {
            $message = $this->request->post['subject']  . "\n";
            $message = htmlspecialchars_decode($this->request->post['message']) . "\n";
            
            

foreach ($emails as $email) {
               $mail = new Mail();   
               $mail->setTo($email);
               $mail->setFrom($this->config->get('config_email'));
                $mail->setSender($this->config->get('config_store'));
                $mail->setSubject($this->request->post['subject']);
               $mail->settext($message);
            }
         }

Important!!

fckeditor is writing in html tags.

Look at

admin/view/template/customer/mail.tpl

and search

Code: Select all

<tr>
        <td><span class="required">*</span> <?php echo $entry_message; ?></td>
        <td><textarea name="message" id="message"><?php echo $message; ?></textarea>
          <?php if ($error_message) { ?>
          <span class="error"><?php echo $error_message; ?></span>
          <?php } ?></td>
      </tr>
    </table>
  </div>
</form>
<script type="text/javascript" src="view/javascript/fckeditor/fckeditor.js"></script>
<script type="text/javascript"><!--
var sBasePath           = document.location.href.replace(/index\.php.*/, 'view/javascript/fckeditor/');
var oFCKeditor          = new FCKeditor('message');
	oFCKeditor.BasePath = sBasePath;
	oFCKeditor.Value	= document.getElementById('message').value;
	oFCKeditor.Width    = '100%';
	oFCKeditor.Height   = '300';
	oFCKeditor.ReplaceTextarea();
//--></script>

Replace

Code: Select all

      <tr>
        <td><span class="required">*</span> <?php echo $entry_message; ?></td>
        <td><textarea name="message" id="message" cols="65" rows="10"><?php echo $message; ?></textarea>
          <?php if ($error_message) { ?>
          <span class="error"><?php echo $error_message; ?></span>
          <?php } ?></td>
      </tr>
    </table>
  </div>
</form>

New member

Posts

Joined
Fri Jun 19, 2009 12:14 am
Who is online

Users browsing this forum: No registered users and 57 guests