CodeIgniter Forums
send html format - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: send html format (/showthread.php?tid=20792)

Pages: 1 2


send html format - El Forum - 07-21-2009

[eluser]tirso[/eluser]
hi to all

What's wrong with my code, This is my first time to use this class. I received it with my email but there is no any contents. I tried to remove ($this->email->mailtype = 'html'Wink and I received it with contents but html element was included.

Thanks in advance

Code:
function send(){
    $message = '<div style="width:400px; border:1px solid #666666">
          <div><p>'.$this->input->post('msg').'</p></div>
          <div><span>Name :</span>'.$this->input->post('name').'</div>
          <div><span>Address :</span>'.$this->input->post('address').'</div>  
          <div><span>Tel No :</span>'.$this->input->post('tel').'</div>    
          <div><span>Mobile No :</span>'.$this->input->post('mobile').'</div>  
          <div><span>Fax No :</span>'.$this->input->post('fax').'</div>    
          <div><span>Email Address :</span>'.$this->input->post('email').'</div>  
        </div>';

    $this->email->mailtype = 'html';        
    $this->email->from('Domesticity.com', $this->input->post('name'));
    $this->email->to('[email protected]');
    $this->email->cc('[email protected]');

    $this->email->subject('contact');
    $this->email->message($message);
    
    if ($this->email->send()){
        redirect('default_c');
    }
    else{
        print '[removed] alert ("Message not successfully sent") [removed]';
    }
}



send html format - El Forum - 07-21-2009

[eluser]umefarooq[/eluser]
hi try the following line of code it will work fine.

Code:
replace
$this->email->mailtype = 'html';

with
$config_email['mailtype'] = 'html';
$this->email->initialize($config_email);



send html format - El Forum - 07-22-2009

[eluser]tirso[/eluser]
Hi,


thanks for your replied, still blank content.

any thoughts...

Thanks

Tirso


send html format - El Forum - 07-22-2009

[eluser]Jay Logan[/eluser]
For HTML e-mails, I do something like this:

Code:
$this->load->library('email');
$email_config['protocol'] = 'smtp';
$email_config['smtp_host'] = 'SERVER';
$email_config['smtp_user'] = 'USER';
$email_config['smtp_pass'] = 'PASS';
$email_config['smtp_port'] = '26';
$this->email->initialize($email_config);
            
$this->email->from('EMAIL ADDRESS', 'Web Administrator');
$this->email->to('RECIPIENT');
            
$this->email->subject('EMAIL SUBJECT');
    
            
$this->email->message($this->load->view('mail/free_estimate', array(
'name_first' => $this->input->post('name_first'),
'name_last' => $this->input->post('name_last'),
'addr_home_street' => $this->input->post('addr_home_street'),
'addr_home_city' => $this->input->post('addr_home_city'),
'addr_home_state' => $this->input->post('addr_home_state'),
'addr_home_zip' => $this->input->post('addr_home_zip'),
'phone_home' => $this->input->post('phone_home'),
'email_home' => $this->input->post('email_home')
), TRUE));
$this->email->send();

Then just make a view file containing the message HTML and use code like &lt;?= $name_first ?&gt; to display info.


send html format - El Forum - 07-22-2009

[eluser]tirso[/eluser]
hi,

thank's for your response, I tried your code but still the same blank contents. I checked the full header in my yahoo account and maybe there is something wrong. Here is the header.


Quote:Return-Path: <[email protected]>
Authentication-Results: mta353.mail.mud.yahoo.com from=; domainkeys=neutral (no sig); from=; dkim=neutral (no sig)
Received: from 208.101.4.115 (EHLO win4.myserverhosts.com) (208.101.4.115) by mta353.mail.mud.yahoo.com with SMTP; Wed, 22 Jul 2009 18:55:12 -0700
Received: from win4 ([127.0.0.1]) by win4.myserverhosts.com with MailEnable ESMTP; Wed, 22 Jul 2009 20:55:05 -0500
Subject: =?utf-8?Q?contact?=
To: tjkgarcia@yahoo.com
User-Agent: CodeIgniter
Date: Wed, 22 Jul 2009 20:55:05 -0500
From:
"asdf" <Domesticity.com>
Add sender to Contacts
Return-Path: <Domesticity.com>
Cc: [email protected]
Reply-To: "Domesticity.com" <Domesticity.com>
Message-ID: <4a67c2f97e912>
Mime-Version: 1.0
Content-Type: multipart/alternative; boundary="B_ALT_4a67c2f97e927" This is a multi-part message in MIME format. Your email application may not support this format. --B_ALT_4a67c2f97e927
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit A PHP Error was encountered
Severity: Notice
Message: Use of undefined constant msg - assumed 'msg'
Filename: views/sendcontactus.php Line Number: 2 msg Name : A PHP Error was encountered
Severity: Notice
Message: Use of undefined constant name - assumed 'name'
Filename: views/sendcontactus.php Line Number: 3 name Address : A PHP Error was encountered
Severity: Notice
Message: Use of undefined constant address - assumed 'address'
Filename: views/sendcontactus.php Line Number: 4 address Tel No : A PHP Error was encountered
Severity: Notice
Message: Use of undefined constant tel - assumed 'tel'
Filename: views/sendcontactus.php Line Number: 5 tel Mobile No : A PHP Error was encountered
Severity: Notice
Message: Use of undefined constant mobile - assumed 'mobile'
Filename: views/sendcontactus.php Line Number: 6 mobile Fax No : A PHP Error was encountered
Severity: Notice
Message: Use of undefined constant fax - assumed 'fax'
Filename: views/sendcontactus.php Line Number: 7 fax Email Address : A PHP Error was encountered
Severity: Notice
Message: Use of undefined constant email - assumed 'email'
Filename: views/sendcontactus.php Line Number: 8 email '; --B_ALT_4a67c2f97e927
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: quoted-printable
Content-Length: 2313



send html format - El Forum - 07-22-2009

[eluser]David Johansson[/eluser]
try to echo your $message before sending the email to see if something is wrong already before the email is sent.


send html format - El Forum - 07-22-2009

[eluser]tirso[/eluser]
Hi,

I did what your suggestion, there is no error with the content. It was displayed the inputted message. here is the full header after some revisions

Quote:Return-Path: <[email protected]>
Authentication-Results: mta525.mail.mud.yahoo.com from=; domainkeys=neutral (no sig); from=; dkim=neutral (no sig)
Received: from 208.101.4.115 (EHLO win4.myserverhosts.com) (208.101.4.115) by mta525.mail.mud.yahoo.com with SMTP; Wed, 22 Jul 2009 19:47:51 -0700
Received: from win4 ([127.0.0.1]) by win4.myserverhosts.com with MailEnable ESMTP; Wed, 22 Jul 2009 21:47:46 -0500
Subject: =?utf-8?Q?contact?=
To: tjkgarcia@yahoo.com
User-Agent: CodeIgniter
Date: Wed, 22 Jul 2009 21:47:46 -0500
From:
"asdf" <Domesticity.com>
Add sender to Contacts
Return-Path: <Domesticity.com>
Cc: [email protected]
Reply-To: "Domesticity.com" <Domesticity.com>
Message-ID: <4a67cf52261e6>
Mime-Version: 1.0
Content-Type: multipart/alternative; boundary="B_ALT_4a67cf52261f4" This is a multi-part message in MIME format. Your email application may not support this format. --B_ALT_4a67cf52261f4
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit adfsasdfasdf Name :asdf Address :asdf Tel No :asdf Mobile No :asdf Fax No :asdf Email Address :test@yahoo.com '; --B_ALT_4a67cf52261f4
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: quoted-printable
Content-Length: 383



send html format - El Forum - 07-22-2009

[eluser]David Johansson[/eluser]
You still have many content-type in the header... maybe you should try to clear the mail variables first with $this->email->clear();


send html format - El Forum - 07-22-2009

[eluser]David Johansson[/eluser]
you could also use the print_debugger function to se everything before sending it: $this->email->print_debugger();


send html format - El Forum - 07-22-2009

[eluser]tirso[/eluser]
hi,

here is the printed result of the debugger. Actually I tried to send a simple html message but still doesn't work.

here is now the code

Code:
$this->load->library('email');
$config['mailtype'] = 'html';
$config['charset'] = 'utf-7';  //even utf-8 still the same output
$config['wordwrap'] = TRUE;
$this->email->initialize($config);

$message = '<b>tirso</b>. has commented on your music!<br /><a href="#">Click here to view your comment!</a>';        
$this->email->from('Domesticity.com', $this->input->post('name'));
$this->email->to('[email protected]');
$this->email->cc('[email protected]');
$this->email->subject('contact');
$this->email->message($message);
$this->email->send();



Quote:Your message has been successfully sent using the following protocol: mail

User-Agent: CodeIgniter
Date: Wed, 22 Jul 2009 22:50:07 -0500
From: "adsf"
Return-Path:
Cc: [email protected]
Reply-To: "Domesticity.com"
X-Sender: Domesticity.com
X-Mailer: CodeIgniter
X-Priority: 3 (Normal)
Message-ID: <4a67ddef5f1d3>
Mime-Version: 1.0
Content-Type: multipart/alternative; boundary="B_ALT_4a67ddef5f1df"

This is a multi-part message in MIME format.
Your email application may not support this format.

--B_ALT_4a67ddef5f1df
Content-Type: text/plain; charset=utf-7
Content-Transfer-Encoding: 8bit

tirso. has commented on your music!Click here to view your comment!


--B_ALT_4a67ddef5f1df
Content-Type: text/html; charset=utf-7
Content-Transfer-Encoding: quoted-printable
=?utf-7?Q?contact?=
<b>tirso</b>. has commented on your music!<br /><a >Click here to=
view your comment!</a>

--B_ALT_4a67ddef5f1df--