Jump to content

PHP Basic Email Problem Help Please


perezf

Recommended Posts

For some reason when i submit from my form,

all the code is displayed in the email itself???

Meaning all of the html, i dont understand why its happening?

???

$from = $_POST['fromemail'];
$htmlstart = "From: $from\r\n"; 
$htmlstart .= "MIME-Version: 1.0\r\n";
$htmlstart .= "Content-type: text/html; charset=iso-8859-1\r\n"; 
mail($_POST['toemail'], $_POST['subject'], $_POST['message'], $htmlstart);
print '<p>Successfully sent to ' . $_POST['toemail'] . '</p>';

Link to comment
https://forums.phpfreaks.com/topic/104394-php-basic-email-problem-help-please/
Share on other sites

try rearranging this bit...

$htmlstart = "From: $from\r\n"; 
$htmlstart .= "MIME-Version: 1.0\r\n";
$htmlstart .= "Content-type: text/html; charset=iso-8859-1\r\n";

to

$htmlstart = "MIME-Version:1.0 \r\n";
$htmlstart .= "Content-type: text/html; charset=iso-8859-1 \r\n";
$htmlstart .= "From: $from"; 

Well assuming your server is set up right i would maybe try something like  :

 

<?php
$to = "[email protected]";
$subject = "Hello";
$body = "Hi,\n\nHow are you?";
if (mail($to, $subject, $body)) {
  echo("<p>Message successfully sent!</p>");
} else {
  echo("<p>Message delivery failed...</p>");
}
?>

 

 

 

Is this what you mean  ?

yes, but i mean setting  it up so i can send html emails.

Because what i have now is not sending graphic emails, all it sends is the html code to me instead.

For example:

Content-type: text/html; charset=iso-8859-1

 

 

<p><strong>just a test</strong></p>

hmmm make a new page and chek if this bit of code works on your server. Also change appropriately...

 

$email="[email protected]"; //who to email to
$headers="MIME-Version:1.0 \r\n";
$headers .= "Content-type: text/html;charset=iso-8859-1 \r\n";
$headers .= 'From: Name <[email protected]>';
$subject = "User [New Account]"; 
$msg = "
<center>hello</center><br />
<b>i</b><u> am personally</u> proud of <i>myself</i>
"; 

mail($email, $subject, $msg, $headers);

 

if that doesnt work then there may be a server issue

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.