Page 1 of 1
PHP Mail - with HTML...?
Posted: Sat Mar 06, 2010 3:51 pm
by simonmlewis
Code: Select all
<?php
$to = 'email@domain.com';
$subject = 'Website Change Reqest';
$headers = "From: noreply@domain.com";
$headers .= "Reply-To: noreply@domain.com";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
$message = '<html><body>';
$message .= '<h1>Hello, World!</h1>';
$message .= '</body></html>';
mail($to, $subject, $message, $headers);
?>
Hello
I want to be able to send out emails via the mail script, but in HTML.
Having read some scripts, it seems pretty straight forward, but the above produces nothing.
Have I missed something?
Do I need to enable something else on the server?
Hope someone can help point me in the right direction. Once I've got this cracked, email marketing will be alot easier!!
Simon
Re: PHP Mail - with HTML...?
Posted: Sat Mar 06, 2010 4:13 pm
by mikosiko
simonmlewis wrote:Hello
I want to be able to send out emails via the mail script, but in HTML.
. Once I've got this cracked, email marketing will be alot easier!!
Simon
read here :
http://www.php.net/manual/en/mail.requirements.php
.... are you tried to look into PHPMailer or SwiftMailer? ... seems better options than mail()
Re: PHP Mail - with HTML...?
Posted: Sat Mar 06, 2010 4:20 pm
by simonmlewis
That page just seems to state that for the mail to work, things must be installed.
Mail *does* work - but html format isn't doing anything.
We dont want to install further software on the web server. Our hosts did suggest those tools, but if we can just get HTML to work - we dont need it.
Re: PHP Mail - with HTML...?
Posted: Sat Mar 06, 2010 4:27 pm
by mikosiko
simonmlewis wrote:That page just seems to state that for the mail to work, things must be installed.
Mail *does* work - but html format isn't doing anything.
We dont want to install further software on the web server. Our hosts did suggest those tools, but if we can just get HTML to work - we dont need it.
well....
Having read some scripts, it seems pretty straight forward, but the above produces nothing.
is different to:
Mail *does* work - but html format isn't doing anything.
hence my mistake....
Re: PHP Mail - with HTML...?
Posted: Sat Mar 06, 2010 4:39 pm
by simonmlewis
Mmmmm maybe.
I said the above does nothing. Which is correct.
Mail works fine when i do 'plain text'.
[RESOLVED] Re: PHP Mail - with HTML...?
Posted: Mon Mar 08, 2010 10:10 am
by simonmlewis
Thanks to all who responded.
Answer was that it should be \n not \n\r.