Jump to content

Mail going into junk box


billy nugz

Recommended Posts

Very new to php and dont really have a good understanding of it. but here is a code I use to send simple text based email. But this keeps going into the junk box and I have no idea why?

[code]<?php
/******************************************************************************\

*******************************************************************************/
/*******************************************************************************/
// Necessary Variables:

$TO = "[email protected]";
// En: E-Mail of mail recipient.
// Fr: E-Mail pour l'envoie.

$DEFAULT_EXIT_PAGE = "confirm.htm";
// En: exit page.
// Fr: page de sortie.

// End  Necessary Variables section
/******************************************************************************/

$headers  = "From: $name <$email>\n"; 
$headers .= "Content-Type: text/plain; charset=iso-8859-1\n";

$message = "";

while (list($key, $val) = each($HTTP_POST_VARS)) {
$message .= "$key : $val\n";
}

$message .= "From: $name <$email>\n";

mail($TO, $subject, $message, $headers);
// En : Send mail
// Fr : Envoi du mail

if(! $exit_page)
$exit_page = $DEFAULT_EXIT_PAGE;

Header("Location: ".$exit_page);
// Exit -> $exit_page

?> [/code]

Is there a better code I could use. I tryed to get a grasp on the php mailer tut and got real lost

Any help would be great. My thanks in advance.
Link to comment
https://forums.phpfreaks.com/topic/36348-mail-going-into-junk-box/
Share on other sites

So somthing like this ? If so would I have to change fromaddress?

[code]<?php
function send_mail($emailaddress, $fromaddress, $emailsubject, $body)
{
  $eol="\r\n";
  $mime_boundary=md5(time());
 
  # Common Headers
  $headers .= 'From: MyName<'.$fromaddress.'>'.$eol;
  $headers .= 'Reply-To: MyName<'.$fromaddress.'>'.$eol;
  $headers .= 'Return-Path: MyName<'.$fromaddress.'>'.$eol;    // these two to set reply address
  $headers .= "Message-ID: <".$now." TheSystem@".$_SERVER['SERVER_NAME'].">".$eol;
  $headers .= "X-Mailer: PHP v".phpversion().$eol;          // These two to help avoid spam-filters

  # Boundry for marking the split & Multitype Headers
  $headers .= 'MIME-Version: 1.0'.$eol;
  $headers .= "Content-Type: multipart/related; boundary=\"".$mime_boundary."\"".$eol;

  $msg = "";
/******************************************************************************\

*******************************************************************************/
/*******************************************************************************/
// Necessary Variables:

$TO = "[email protected]";
// En: E-Mail of mail recipient.
// Fr: E-Mail pour l'envoie.

$DEFAULT_EXIT_PAGE = "confirm.htm";
// En: exit page.
// Fr: page de sortie.

// End  Necessary Variables section
/******************************************************************************/



$message = "";

while (list($key, $val) = each($HTTP_POST_VARS)) {
$message .= "$key : $val\n";
}

$message .= "From: $Name <$Email>\n";

mail($TO, $subject, $message, $headers);
// En : Send mail
// Fr : Envoi du mail

if(! $exit_page)
$exit_page = $DEFAULT_EXIT_PAGE;

Header("Location: ".$exit_page);
// Exit -> $exit_page

?> [/code]

Thanks again guys

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.