Jump to content

Recommended Posts

Hi

 

I am trying to send html emails to users when they register on a site.

 

I am using the code below

<?php
//email settings
$to=$_POST['user_name'];
$from="Trade-Bidz <[email protected]>";
$subject = "Trade-Bidz Registration Confirmation";
$content = "Hello ".$_POST['contact_name']."<p>Welcome to <a href=\"http://www.trade-bidz.co.uk\">Trade-Bidz</a>.  Add us to your Favourite and make it quicker to sell your part exchanges.</p><p>Your Login details are below, you will need these to be able to sell your vehicles and to be able to place bids on other vehicles</p>
<p>Email Address:".$_POST['user_name']."<br/>
Password:".$_POST['password']."</p>
<p>We hope you have great success with Trade-Bidz.</p>

<p>Kind Regards</p>

<p>The Trade-Bidz Team</p>";
$message=('<html><head>


<link href="http://www.trade-bidz.co.uk/style/trade-bidz.css" rel="stylesheet" type="text/css" />
</head>

<body>
<div id="header">
</div>
<img src="http://www.trade-bidz.co.uk/images/logo.jpg" width="300" /></div>
<div id="content">'. $content.'</div>
<div id="footer">© Trade-Bidz 2011</div>
</body></html>');
$headers ="MIME-Version: 1.0rn";
$headers .= "Content-type : text/html; charset=iso=8859-1rn";
$headers .= "From: $from\r\n";
$headers .= "Reply-To: [email protected]";

mail($to, $subject, $message, $headers);

echo ('Registration email has been sent');
?>
When the user registers, the code displays as a page in the browser, and the email that is sent displays the html code

What am I doing wrong?

Link to comment
https://forums.phpfreaks.com/topic/233880-send-html-emails/
Share on other sites

Hi

 

I have amended the code, which now looks like

 

<?php
//email settings
$to=$_POST['user_name'];
$from="Trade-Bidz <[email protected]>";
$subject = "Trade-Bidz Registration Confirmation";
$content = "Hello ".$_POST['contact_name']."<p>Welcome to <a href=\"http://www.trade-bidz.co.uk\">Trade-Bidz</a>.  Add us to your Favourite and make it quicker to sell your part exchanges.</p><p>Your Login details are below, you will need these to be able to sell your vehicles and to be able to place bids on other vehicles</p>
<p>Email Address:".$_POST['user_name']."<br/>
Password:".$_POST['password']."</p>
<p>We hope you have great success with Trade-Bidz.</p>

<p>Kind Regards</p>

<p>The Trade-Bidz Team</p>";
$message=('<html><head>


<link href="http://www.trade-bidz.co.uk/style/trade-bidz.css" rel="stylesheet" type="text/css" />
</head>

<body>
<div id="header">
</div>
<img src="http://www.trade-bidz.co.uk/images/logo.jpg" width="300" /></div>
<div id="content">'. $content.'</div>
<div id="footer">© Trade-Bidz 2011</div>
</body></html>');
$headers ="MIME-Version: 1.0\r\n";
$headers .= "Content-type : text/html; charset=iso=8859-1\r\n";
$headers .= "From: $from\r\n";
$headers .= "Reply-To: [email protected]";

mail($to, $subject, $message, $headers);

echo ('Registration email has been sent');
?>

 

The message is being displayed in a browser, I want to stop the message displaying ina browser, and the email that is received is blank.

 

Please help me.

Link to comment
https://forums.phpfreaks.com/topic/233880-send-html-emails/#findComment-1202664
Share on other sites

I copied that code to a new script file, put in my email address for TO and FROM. And ran it. The message was not displayed in the browser (except for the "Registration email has been sent" message that you echo at the end) and the email I received contained the text from your script - including the image (which is pretty cool).

 

In other words, that code works exactly as you want it to, for me.

Link to comment
https://forums.phpfreaks.com/topic/233880-send-html-emails/#findComment-1202808
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.