CodeIgniter Forums
problem sending html email - 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: problem sending html email (/showthread.php?tid=17619)



problem sending html email - El Forum - 04-09-2009

[eluser]PermanaJ[/eluser]
I got problem when trying to sending HTML email. The email was sent but I cannot read the email. The result is like picture below

http://i264.photobucket.com/albums/ii162/mypermana/scrshoot.jpg

I have a view for HTML email application/views/mail/mailtest.php
Code:
<html>
<body>
<STYLE>
body{
    background-color:#f9f9f9;
    font-family:12px;
}
h1 {
    color: #444;
    background-color: transparent;
    border-bottom: 1px solid #D0D0D0;
    font-size: 16px;
    font-weight: bold;
}
</STYLE>
<h1>Hello, &lt;?php echo $name; ?&gt;</h1>
<p>How are you ?</p>
</p>
&lt;/body&gt;
&lt;/html&gt;

and i have this controller application/controller/test.php
Code:
&lt;?php
class Test extends Controller{
    public function __construct() {
        parent::Controller();
    }

    public function testemail() {
        $this->load->library('email');

        $vars ['name'] = 'Tony Stark';
        $body = $this->load->view('mail/mailtest', $vars, true);

        $config['mailtype'] = 'html';

        $this->email->initialize($config);
        $this->email->from('[email protected]', 'Permana');
        $this->email->to('devtest1@localhost');
        $this->email->subject('Email test');
        $this->email->message($body);

        $this->email->send();
    }
}

?&gt;



problem sending html email - El Forum - 04-09-2009

[eluser]NogDog[/eluser]
Maybe stick in a little debug code to verify that $body has been populated?


problem sending html email - El Forum - 04-10-2009

[eluser]TheFuzzy0ne[/eluser]
Another thing to try, might be to check the source code of the received message.


problem sending html email - El Forum - 04-14-2009

[eluser]bsauls[/eluser]
Family Values
I don't know that this would cause the problem, but 12px is not a font-family value.
Something like
font-family: sans-serif;
font-size: 12px;
would work
Also, you have two close para tags instead of one. Again, it doesn't seem like a couple of syntax errors would cause the problem, but I basically replicated your code minus these errors and it worked.
function sendmail2()
{
$config['mailtype'] = 'html';
$config['wordwrap'] = TRUE;
$this->email->initialize($config);

$firstname = 'Celia';
$lastname = 'Cardholder';
$email = '[email protected]';
$passwd = '1Whatever';
$this->load->library('Email');
$this->email->from('[email protected]', 'Your Website');
$this->email->to('[email protected]');
$this->email->bcc('[email protected]');
$this->email->subject('Registration for My Website');
$message ='We hope that online access to our inventory will be a great convenience for you. You are now registered as '.$firstname.' '.$lastname.'.
<br>
<br>
Go to <a href="http://www.yourwebsite.com/member/login">http://www.yourwebsite.com</a> and logon using: '.$email.' with password: '.$passwd.'
<br>
<br>
Regards
<br>
<br>
My Website';
$vars['message'] = $message;
$body = $this->load->view('mail/welcome', $vars, true);
$this->email->message($body);
$this->email->send();

echo $this->email->print_debugger();
}


problem sending html email - El Forum - 05-10-2009

[eluser]PermanaJ[/eluser]
when i try using the print debugger, there are some message like this

Code:
...
Mime-Version: 1.0
Content-Type: multipart/alternative; boundary="B_ALT_4a07ac093fe3f"
This is a multi-part message in MIME format.
Your email application may not support this format.

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




--B_ALT_4a07ac093fe3f
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: quoted-printable
Email Test


--B_ALT_4a07ac093fe3f--

what does it mead ? does it mean that the email format still in plain text ... ?


problem sending html email - El Forum - 05-10-2009

[eluser]PermanaJ[/eluser]
new problem when I upload the script, they cannot send email ... what will be the setting on the server .. ?


problem sending html email - El Forum - 05-10-2009

[eluser]Cro_Crx[/eluser]
Your email settings will depend on the machine that your running it on or you host. If you have a shared web server your host will set it up for you so you might want to contact them if your having issues. If your running a local machine or have a dedicated server your going to have to setup your SMTP settings in the php.ini file yourself.

Alternativly you can use the SMTP settings in the email class, but setting the settings on the server itself would be much better. Codeigniter SMTP settings can be set in the email class http://ellislab.com/codeigniter/user-guide/libraries/email.html

Good luck


problem sending html email - El Forum - 05-10-2009

[eluser]PermanaJ[/eluser]
[quote author="Cro_Crx" date="1242036862"]Your email settings will depend on the machine that your running it on or you host. If you have a shared web server your host will set it up for you so you might want to contact them if your having issues. If your running a local machine or have a dedicated server your going to have to setup your SMTP settings in the php.ini file yourself.

Alternativly you can use the SMTP settings in the email class, but setting the settings on the server itself would be much better. Codeigniter SMTP settings can be set in the email class http://ellislab.com/codeigniter/user-guide/libraries/email.html

Good luck[/quote]

thankyou very much, I just mail the host. Im on shared web server ... Oh actually, my hosting account is set up for example.net but i create folder example and add a domain example.com, is there will be causing any problem ... ? I personally think it wont, but i want to know what others think

[sorry for bad english]


problem sending html email - El Forum - 05-20-2009

[eluser]PermanaJ[/eluser]
Ok, Looks like I can send HTML message using SMTP protocol. And still cannot send email using mail function ...