• Howdy! Welcome to our community of more than 130.000 members devoted to web hosting. This is a great place to get special offers from web hosts and post your own requests or ads. To start posting sign up here. Cheers! /Peo, FreeWebSpace.net
managed wordpress hosting

Php email help

Divine Hosting

New Member
Im trying too add html in my email List
Can anyOne help?
When It Send's Out,It Only Send's the html Code,I want images,link's ect To Work
if(isset($_POST['submit'])) { $nletter=$_POST['nletter']; $subject=$_POST['subject']; $nletter=stripslashes($nletter); $subject=stripslashes($subject); $selectmails="SELECT * from m_list where validated='1' and mailed='0'"; $selectmails2=mysql_query($selectmails) or die("Could not select mails"); while($selectmails3=mysql_fetch_array($selectmails2)) { mail("$selectmails3[address]","$subject","$nletternUnsubscribe here (http://www.djluisonline.com/mailinglist/index.php)","From: $yourmail"); $setassend="update m_list set mailed='1' where mailid='$selectmails3[mailid]'"; mysql_query($setassend) or die("COuld not set as send"); } print "Newsletter Sent";
 
In the headers, you need to set "Content-type: text / html \n\n"

That will then tell the email client that the email is in HTML and not RTF.
 
PHP:
mail( 'you@you.com', 'The Subject', '<b>The html message</b>', "Content-Type: text/html\r\nFrom: Your Name <me@me.com>\r\n" );
 
PHP:
<?php
function multi_html_email( $emails, $subject, $message )
{
	foreach( $emails as $email )
	{
		if( !mail( $email, $subject, $message, 
			"Content-Type: text/html\r\n" ) )
		{
			printf( "Cannot send email \"%s\" to \"%s\"", $subject, $email );
			return false ;
		}
	}
	return true ;
}

$emails = array( 
	'first@email.com',
	'second@email.com',
	'third@email.com'
);

$subject = "Subject for message";
$message = "The <b>bold</b> text is formatted";

if( multi_html_email( $emails, $subject, $message ) )
{
	printf("Email sent to %d people", count( $emails ) );	
}
?>
 
What i got is a mailing list,sql Saved email's
So these are the functions that i got working Bellow,Just wont send html

'nletter' is the message
'subject' subject
$selectmails="SELECT * from m_list pulling emils from the sql i guess?

PHP:
if(isset($_POST['submit'])) { $nletter=$_POST['nletter']; $subject=$_POST['subject']; $nletter=stripslashes($nletter); $subject=stripslashes($subject); $selectmails="SELECT * from m_list where validated='1' and mailed='0'"; $selectmails2=mysql_query($selectmails) or die("Could not select mails"); while($selectmails3=mysql_fetch_array($selectmails2)) { mail("$selectmails3[address]","$subject","$nletternUnsubscribe here (http://www.djluisonline.com/mailinglist/index.php)","From: $yourmail"); $setassend="update m_list set mailed='1' where mailid='$selectmails3[mailid]'"; mysql_query($setassend) or die("COuld not set as send"); } print "Newsletter Sent";
 
PHP:
if(isset($_POST['submit'])) { $nletter=$_POST['nletter']; $subject=$_POST['subject']; $nletter=stripslashes($nletter); $subject=stripslashes($subject); $selectmails="SELECT * from m_list where validated='1' and mailed='0'"; $selectmails2=mysql_query($selectmails) or die("Could not select mails"); while($selectmails3=mysql_fetch_array($selectmails2)) { mail("$selectmails3[address]","$subject","$nletternUnsubscribe here (http://www.djluisonline.com/mailinglist/index.php)","From: $yourmail", "Content-type: text/html\r\n"); $setassend="update m_list set mailed='1' where mailid='$selectmails3[mailid]'"; mysql_query($setassend) or die("COuld not set as send"); } print "Newsletter Sent";
 
Message came back undeliverable
A message that you sent contained a recipient address that was incorrectly
constructed:

Content-type: missing or malformed local part (expected word or "<")

The message has not been delivered to any recipients.

------ This is a copy of your message, including all the headers. ------
 
Still dont get it
Full page Code here

PHP:
<?php
session_start();
include "connect.php";
?>
<link rel="stylesheet" href="style.css" type="text/css">
<center><table border='0'><tr><td valign='top' width=30%>
<?php
if(isset($_SESSION['mailadmin']))
{
   include "left.php";
   print "</td>";
   print "<td valign='top' width=70%>";
   print "<table class='maintable'><tr class='headline'><td><center>Send Newsletter</center></td></tr>";
   print "<tr class='mainrow'><td>";
   if(isset($_POST['submit']))
   {
      $nletter=$_POST['nletter'];
      $subject=$_POST['subject'];
      $nletter=stripslashes($nletter);
      $subject=stripslashes($subject);
      $selectmails="SELECT * from m_list where validated='1' and mailed='0'";
      $selectmails2=mysql_query($selectmails) or die("Could not select mails");
      while($selectmails3=mysql_fetch_array($selectmails2))
      {
         mail("$selectmails3[address]","$subject","$nletter\nUnsubscribe here (http://www.djluisonline.com/mailinglist/index.php)","From: $yourmail");
         $setassend="update m_list set mailed='1' where mailid='$selectmails3[mailid]'";
         mysql_query($setassend) or die("COuld not set as send");
      }
      print "Newsletter Sent";
   }
   else
   {
      print "<form action='sendletter.php' method='post'>";
      print "Subject:<br>";
      print "<input type='text' name='subject' size='20'><br>";
      print "Letter to send:<br>";
      print "<textarea name='nletter' rows='6' cols='40'></textarea><br>";
      print "<input type='submit' name='submit' value='submit'></form>";

   }
   print "</td></tr></table>";
}
?>
 
Back
Top