2017-07-03 48 views
0

我'嘗試發送簡訊圖像到我的所有用戶的笨,但得到未定義的屬性錯誤,有人可以幫我嗎?我的代碼是我如何發送簡訊形象我的笨的所有用戶

視圖

 <form method="POST" action="<?php echo 
    base_url();>Newsletter_Controller/sendnewsletter" 
    enctype="multipart/form-data" > 
      <div class="box-body"> 
      <div class="form-group col-lg-4 col-md-4 col-sm-12"> 
       <label for="newsletter" class="col-xs-12">Upload 
       Newsletter</label> 
       <input type="file" id="newsletter" name="newsletter" 
       class="col-xs-12"> 
      </div> 

      <div class="clearfix"></div> 
      <!-- /.box-body --> 
      <div class="box-footer"> 
       <button type="submit" class="btn btn-primary">Send to 
        Subscriber's</button> 
      </div> 
     </div> 
     </form> 

我的控制器

+0

粘貼代碼發送電子郵件 –

回答

0

請在以下提到須藤代碼。落實並改變它取決於你的需求。

// This will use to send individual email to each user individually 
public function sendnewsletter(){ 
    $recipient_list= array(); 
    $subscribers = // Get all subscribers from database 
    $this->load->library('email'); 
    $this->email->set_header('MIME-Version', '1.0; charset=utf-8'); 
    $this->email->set_header('Content-type', 'text/html'); 
    foreach($subscribers as $subscriber): 
     $recipient_list[] = $subscriber['email']; 
    endforeach; 
    $this->email->from('[email protected]', 'Your Name'); 
    $this->email->to($recipient_list); 
    $this->email->subject('Email Test'); 
    $this->email->message('<img src="/path/to/photo1.jpg" />'); 
    $this->email->send(); 

} 

讓我知道你是否需要任何幫助。

+0

您好,我想在郵件發送圖像而不是作爲一個附件和郵件應當向所有在同一時間,你能告訴我該怎麼辦呢? –

+0

請檢查我更新的答案相同 –

0

可以在HTML格式發送電子郵件。使用$config['mailtype'] = 'html';

$this->load->helper('url'); 
     $this->load->helper('form'); 
     $this->load->library('email'); 
        $config['protocol'] = 'mail'; 
        $config['mailtype'] = 'html'; 
        $config['mailpath'] = ''; 
        $config['charset'] = 'iso-8859-1'; 
        $config['crlf'] = '\r\n'; 
        $config['wordwrap'] = TRUE; 
        $this->email->initialize($config); 
        $baseurl = base_url(); 
    $this->email->from('[email protected]'); 
    $this->email->to('[email protected]'); 

    $content_head = '<html> 
     <head> 
     <title>emailer</title> 
     <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> 
     </head> 
    <body bgcolor="#f1f1f1" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0"> 
    <table width="600" cellpadding="0" cellspacing="0" border="0" align="center"> 
        <tr> 
          <td align="left" valign="top"> 
    <img src="'.base_url().'assets/images/email_banner.JPG" width="600" height="137" ></td> 
        </tr>'; 
$this->email->message($content);    
$this->email->send(); 
相關問題