Jump to content

sending email to user


jac.kock

Recommended Posts

hi all,

 

im working on a email send to de user who register on the website!

 

now i get the email but its not email/html view and it gets in to the unwanted folder, also as i siad trust this emailadress!

what do i wrong in the code??

 

the whole php file see //#### XXX ### where i need help!

<?php
Session_start();

if(file_exists("support/functions_alg.php"))				// user,pass and database file
{
  include("support/functions_alg.php"); 		   			// database functions file
}

if($_REQUEST)
{
$email=$_REQUEST['email'];
$pass=md5( $_REQUEST['pass'] );
$secc=md5( $_REQUEST['sec_code'] );

function check_code($secc) 
{
  if($secc == $_REQUEST['mdcode'])
  {
  	return true;
  }
  else
  {
	return false;
  }
}	

function check_email_address($email) 
{
  // First, we check that there's one @ symbol, and that the lengths are right
      if (!ereg("^[^@]{1,64}@[^@]{1,255}$", $email)) 
  {
        // Email invalid because wrong number of characters in one section, or wrong number of @ symbols.
        return false;
       }
    
  // Split it into sections to make life easier
      $email_array = explode("@", $email);
  $local_array = explode(".", $email_array[0]);
  for ($i = 0; $i < sizeof($local_array); $i++) 
  {
        if (!ereg("^(([A-Za-z0-9!#$%&'*+/=?^_`{|}~-][A-Za-z0-9!#$%&'*+/=?^_`{|}~\.-]{0,63})|(\"[^(\\|\")]{0,62}\"))$", $local_array[$i])) 
	{
	  return false;
        }
      }
      if (!ereg("^\[?[0-9\.]+\]?$", $email_array[1])) 
  { 
  	// Check if domain is IP. If not, it should be valid domain name
        $domain_array = explode(".", $email_array[1]);
	if (sizeof($domain_array) < 2) 
	{
	  return false; 
	  // Not enough parts to domain
        }
    
    for ($i = 0; $i < sizeof($domain_array); $i++) 
	{
          if (!ereg("^(([A-Za-z0-9][A-Za-z0-9-]{0,61}[A-Za-z0-9])|([A-Za-z0-9]+))$", $domain_array[$i])) 
	  {
		return false;
          }
        }
      }
      return true;
    }

if(check_email_address($email))
{
  if(check_code($secc))
  {
    //$res=register($email,$pass,$name,$address,$huisnr,$zipcode,$plaats,$dob_year,$dob_month,$dob_date,$tel);
    $res=true;
	if($res==true)
    {
// ##### XXX #####		  
//mail function
    	  /* subject */
	  $subject = "Activeer uw Profiel";
	  /* To send HTML mail, you can set the Content-type header. */
	  $headers  = "MIME-Version: 1.0 \r\n";
	  $headers .= "Content-type: text/html; charset=utf-8 \r\n";

	  /* additional headers */
	  $headers .= "From: " . $mailme . " \r\n";
	  /* and now mail it */

	  $text = '
	  <html>
	  <head>
	  <title>Nieuw profiel</title>
	  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	  </head>
	  <body>
	  Activeer uw profiel op:<br><br>
	  <a href="http://'.$_SERVER['SERVER_NAME'].'/?reg_result&activatie=true">Activeer</a>br><br>
	  Veel plezier op onze website!
	  </body>
	  </html>';

	  $res = mail($email,$subject,$text,$headers);
	  
	  echo("<script>document.location.href='index.php?topic=reg_result&".$res."'</script>");
	  //header('location: "'.$_SERVER['HTTP_REFERER'].'?topic=reg_result&true"');
//###### XXXX #######
	}
	else
	{
	  echo "<table border=1 class=outer_tbl align=center width=50% style='border-collapse:collapse;'>";
	  echo "<tr><td align=center>";
	  echo "Fout tijdens registratie<br><a href='javascript:history.back();'>Klik hier</a> om opnieuw te proberen";	
	  echo "</tr></td></table>";
	}
      }
  else
  {
	echo("<script>document.location.href='".$_SERVER['HTTP_REFERER']."&error=code'</script>");
	//header('location: "'.$_SERVER['HTTP_REFERER'].'&error=code"');		
  } 
}
else
{
  echo("<script>document.location.href='".$_SERVER['HTTP_REFERER']."&error=email'</script>");
  //header('location: "'.$_SERVER['HTTP_REFERER'].'&error=email"');
}
}
?>

 

the recived email looks like :

 

Content-type: text/html; charset=utf-8  From: info@pc-hulp-online.nl

Return-Path: anonymous@server70.hosting2go.nl

X-OriginalArrivalTime: 30 Apr 2012 10:47:41.0985 (UTC) FILETIME=[AB19D110:01CD26BE]

 

 

 

  <html>

  <head>

  <title>Nieuw profiel</title>

  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

  </head>

  <body>

  Activeer uw profiel op:<br><br>

  <a href="http://nieuw.pc-hulp-online.nl/?reg_result&activatie=true">Activeer</a>br><br>

  Veel plezier op onze website!

  </body>

  </html>

 

please help me!!

 

thnx,

Link to comment
https://forums.phpfreaks.com/topic/261835-sending-email-to-user/
Share on other sites

  Quote

  Quote

Have you read the examples in the manual? See mail. In particular, example #4.

 

hi,

 

i have read it and change the lines but still no html view and still in the unwanted folder???

 

can you be specific??

 

thnx,

 

now i have it in html view but stil in the unwanted folder how can i make sure that it comes in the folder mail in??

 

thnx,

You can install phpmailer (http://phpmailer.worxware.com/) on the server if that's an option, lots of people say it helps them.

Also correct formatting helps a lot, and you may have to set a Sender Policy Framework (see http://www.openspf.org/).

But tough spam filters will gladly stop any mails thinking they are spam.

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.