2011-06-08 19 views
6

मुझे कोडिनेटर में ईमेल क्लास के माध्यम से भेजे गए ईमेल के साथ समस्याएं हैं जो एचटीएमएल व्यू के बजाय ईमेल संदेश में स्रोत HTML कोड प्रदर्शित करते हैं। परीक्षण के लिए, मैं वर्तमान में विंडोज पर एक्सएएमपीपी पर सीआई कर रहा हूं, और जीमेल एसएमटीपी का उपयोग उसी जीमेल पते पर भेजने के लिए कर रहा हूं।एचटीएमएल स्रोत (कोडिनेटर ईमेल क्लास) प्रदर्शित करने वाले ईमेल में एचटीएमएल ईमेल परिणाम भेजना

समारोह ईमेल भेजता है कि इस प्रकार है:

$config = Array(
     'protocol' => 'smtp', 
     'smtp_host' => 'ssl://smtp.googlemail.com', 
     'smtp_port' => 465, 
     'smtp_user' => '[email protected]', 
     'smtp_pass' => 'mygmailpassword', 
     ); 

    $this->load->library('email', $config); 
    $this->email->from($this->config->item('webmaster_email', 'tank_auth'), $this->config->item('website_name', 'tank_auth')); 
    $this->email->reply_to($this->config->item('webmaster_email', 'tank_auth'), $this->config->item('website_name', 'tank_auth')); 
    $this->email->to($email); 
    $this->email->subject(sprintf($this->lang->line('auth_subject_'.$type), $this->config->item('website_name', 'tank_auth'))); 
    $this->email->message($this->load->view('email/'.$type.'-html', $data, TRUE)); 
    $this->email->set_alt_message($this->load->view('email/'.$type.'-txt', $data, TRUE)); 

    $this->email->set_newline("\r\n"); // require this, otherwise sending via gmail times out 

    $this->email->send(); 

भेजे गए पाठ संस्करण प्राप्त करने में कोई समस्या नहीं है। लोड किया गया दृश्य एक HTML फ़ाइल है जिसे ईमेल किया जाएगा।

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 
<html> 
<head><title>Welcome to <?php echo $site_name; ?>!</title></head> 
<body> 
<div style="max-width: 800px; margin: 0; padding: 30px 0;"> 
<table width="80%" border="0" cellpadding="0" cellspacing="0"> 
<tr> 
<td width="5%"></td> 
<td align="left" width="95%" style="font: 13px/18px Arial, Helvetica, sans-serif;"> 
<h2 style="font: normal 20px/23px Arial, Helvetica, sans-serif; margin: 0; padding: 0 0 18px; color: black;">Welcome to <?php echo $site_name; ?>!</h2> 
Thanks for joining <?php echo $site_name; ?>. We listed your sign in details below, make sure you keep them safe.<br /> 
To verify your email address, please follow this link:<br /> 
<br /> 
<big style="font: 16px/18px Arial, Helvetica, sans-serif;"><b><a href="<?php echo site_url('/auth/activate/'.$user_id.'/'.$new_email_key); ?>" style="color: #3366cc;">Finish your registration...</a></b></big><br /> 
<br /> 
Link doesn't work? Copy the following link to your browser address bar:<br /> 
<nobr><a href="<?php echo site_url('/auth/activate/'.$user_id.'/'.$new_email_key); ?>" style="color: #3366cc;"><?php echo site_url('/auth/activate/'.$user_id.'/'.$new_email_key); ?></a></nobr><br /> 
<br /> 
Please verify your email within <?php echo $activation_period; ?> hours, otherwise your registration will become invalid and you will have to register again.<br /> 
<br /> 
<br /> 
<?php if (strlen($username) > 0) { ?>Your username: <?php echo $username; ?><br /><?php } ?> 
Your email address: <?php echo $email; ?><br /> 
<?php if (isset($password)) { /* ?>Your password: <?php echo $password; ?><br /><?php */ } ?> 
<br /> 
<br /> 
Have fun!<br /> 
The <?php echo $site_name; ?> Team 
</td> 
</tr> 
</table> 
</div> 
</body> 
</html> 

कोई भी विचार एचटीएमएल ईमेल कैसे प्राप्त किया जाए इसके स्रोत कोड को प्रदर्शित करने के बजाय भेजा जा सकता है?

+0

आपको एक ईमेल में पीएचपी नहीं हो सकता तन। मुझे यह भी यकीन नहीं है कि आपको या टैग की आवश्यकता है। – Nik

+0

@Nik: PHP * उत्पन्न * HTML है जो भेजा जाता है, यह वास्तव में * ईमेल बॉडी में नहीं है। –

+0

ईमेल में एचटीएमएल दूसरा कोड सेगमेंट नहीं है? वहां PHP है। जाहिर है पहला कोड खंड पीढ़ी है। – Nik

उत्तर

1
Set $config['protocol'] = "sendmail"; 

तय किया है कि मेरे लिए

15

इस

$this->email->set_mailtype("html"); 
+0

यह काम करता है, धन्यवाद –

+0

इसके लिए धन्यवाद, वास्तव में बाहर निकलें। दो बार सेट करने की आवश्यकता है? या $ this-> load-> लाइब्रेरी ('ईमेल', $ config) के अंदर; $ config यह काम नहीं कर रहा है। धन्यवाद फिर से –

3

प्रयास करें लाइन कॉम संलग्न mented नीचे दिए गए उदाहरण में:

$config['protocol'] = 'sendmail'; 
$config['mailpath'] = '/usr/sbin/sendmail'; 
$config['charset'] = 'iso-8859-1'; 
$config['wordwrap'] = TRUE; 
$config['mailtype'] = 'html'; // Append This Line 
$this->email->initialize($config); 
4

अपने CodeIgniter मेल पुस्तकालय

$this->email->set_header('MIME-Version', '1.0; charset=utf-8'); 
$this->email->set_header('Content-type', 'text/html'); 

पूर्ण विन्यास लोड करने के बाद इन दो पंक्तियों में जोड़ें: https://stackoverflow.com/a/38740292/4376484

+2

अपरिभाषित विधि पर कॉल करें CI_Email :: set_header() –

संबंधित मुद्दे