Welcome Guest, Not a member yet? Register   Sign In
problem sending html email
#1

[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...rshoot.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;
#2

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

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

[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();
}
#5

[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 ... ?
#6

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

[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-gui...email.html

Good luck
#8

[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-gui...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]
#9

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




Theme © iAndrew 2016 - Forum software by © MyBB