Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

php mail script keeps going to junk mail folder

Status
Not open for further replies.

Kurt111780

Technical User
Nov 20, 2003
235
GB
Hello,

I have a php email script. No matter what i seem to do it keeps going to the users junk folder when sent to outlook, msn, or yahoo. How can I keep it from going to the junk mail folder? I am using bcc but i removed that with no luck. What can I do?

Code:
<?php
 // ************ Begin Email script *****************

//set Variables
	//$toEmail 	= "me@msn.com";
	// $toName 	= "To Kurt";
	$to		= $toName . " <" . $toEmail . ">";
	$fromEmail 	= "me@mydomain.com";
	$fromName	= "from Kurt";
	$from	= $fromName . " <" . $fromEmail . ">";
	$subject	='email form';
  

$body = "
<html>
<body>
<table border=\"1\" cellpadding=\"0\" cellspacing=\"0\" width=\"500\" height=\"500\" bordercolor=\"#669999\">

<tr><td height=\"125\" valign=\"middle\">
<img src=\"[URL unfurl="true"]http://www.mydomain.com/php/mail/smLogo.gif\"[/URL] border=\"0\" alt=\"my Logo\">
</td></tr>

<tr>
<td valign=\"top\">
<b>The files requested are ready for download.</b>
<br>
<a href=\"[URL unfurl="true"]http://www.mydomain.com/php/download.php?pageID=$pageID\">Download[/URL] Files</a>
<font color=\"red\">here</font>

</td></tr>
</table>
</body>
</html>
";
  
  /* Specify your SMTP Server, Port and Valid From Address */
  ini_set("SMTP","mail.mydomain.com");
  ini_set("smtp_port","25");
  ini_set("sendmail_from",$fromEmail);

  // Additional Headers
 $headers = "Bcc:" . $from . "\r\n";
	
	//specify MIME version 1.0
	$headers .= "Content-Type: text/html; charset=iso-8859-1\n";

  
  
  // Try to send message and respond if it sends or fails.
  if(mail ($to, $subject, $body, $headers ))
  {
      echo "<h2>Your Message was sent!</h2>";
  }
  else
  {
      echo "<font color='red'><h2>Your Message Was Not Sent!</h2></font>";
  }
  exit;
 //***************** End Email Script **********************
?>

It's only easy when you know how.
 
The SPAM alogorithms use all kinds of references to determine the probability of SPAM. It might have very little to do with the content of the mail - it could be that your score is high because your SMTP server is a known spamming IP, or it is a host with changing IPs, blacklisted etc. ALso, does the SMTP servers IP resolve to the domain in the from address?
Many things to check out.

In general, with all mail issues, I recommend PHPMailer, a class that produces clean mail pieces with all kinds of options.
 
Can I use PHPMailer when I do not have access to the server, only the web directory?

The web server has a different ip than the mail.mydomain.com server if thats what your asking. I used dnsstuff.com and neither are listed in spam databases.

Kurt

It's only easy when you know how.
 
You can use PHPMailer since it is a PHP class.
The host should have mail capabilities for you. What OS is the server running?
 
I have to apologize - I misread and assumed the mail was bouncing. But, it isn't.
What is the SPAM score that the mail receives? Can you inspect a specimen and the headers in the Junk Mail folder?
 
I would like to use phpMailer but I dont understand the installation.

Copy class.phpmailer.php into your php.ini include_path. If you are
using the SMTP mailer then place class.smtp.php in your path as well.

I don't have access to php.ini.

It's only easy when you know how.
 
You do not need access to php.ini. You do not need access to any server configuration files.

Simply copy the class files to your web document folder and include() them.

Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Ok, I did copy all the files to a directory and tried the sample script in the readme but I keep getting the error.

[red]Mailer Error: Language string failed to load: recipients_failed [/red]

Code:
<?php
require("class.phpmailer.php");
require("phpmailer.lang-en.php");

$mail = new PHPMailer();

$mail->IsSMTP();                                      // set mailer to use SMTP
$mail->Host = "mail.mydomain.com";  // specify main and backup server
$mail->SMTPAuth = false;     // turn on SMTP authentication
$mail->Username = "jswan";  // SMTP username
$mail->Password = "secret"; // SMTP password

$mail->From = "kurt@mydomain.com";
$mail->FromName = "from Kurt";
$mail->AddAddress("me@msn.com.com", "Kurt D");
//$mail->AddAddress("ellen@example.com");                  // name is optional
//$mail->AddReplyTo("info@example.com", "Information");

$mail->WordWrap = 50;                                 // set word wrap to 50 characters
//$mail->AddAttachment("/var/tmp/file.tar.gz");         // add attachments
//$mail->AddAttachment("/tmp/image.jpg", "new.jpg");    // optional name
$mail->IsHTML(true);                                  // set email format to HTML

$mail->Subject = "Here is the subject";
$mail->Body    = "This is the HTML message body <b>in bold!</b>";
$mail->AltBody = "This is the body in plain text for non-HTML mail clients";

if(!$mail->Send())
{
   echo "Message could not be sent. <p>";
   echo "Mailer Error: " . $mail->ErrorInfo;
   exit;
}

echo "Message has been sent";
?>

It's only easy when you know how.
 
Could it be the double '.com'?
Code:
$mail->AddAddress("me@msn[COLOR=red].com.com[/color]", "Kurt D");
 
Hi, Thanks but that wasn't it. That was a typo on the forum. I didn't actually have that.

It was actualy this line

Code:
//$mail->AddReplyTo("info@example.com", "Information");

I guess thats required. I assumed it would use the from address.

Kurt

It's only easy when you know how.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top