PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > alt.php > PHP Mail gets blocked by spam filters
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
PHP Mail gets blocked by spam filters

Réponse
 
LinkBack Outils de la discussion
Vieux 03/09/2007, 17h25   #1
jason.m.ho@gmail.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut PHP Mail gets blocked by spam filters

Hello,
I need to be able to send email in PHP without it getting filtered by
spam filters. Gmail usually filters all email sent using the "mail()"
function. I've looked on the forums, and am using the function below.
However, it seems to display alot of the meta data inside the email
itself. Is there something I'm doing wrong? Does anyone have any
suggestions/example that will send a well-formed email (with all the
meta data in tact)?

Thanks in advance,
Jason Ho
Founder Clockspot.net
http://www.clockspot.net


function send_mail($to, $body, $subject, $fromaddress, $fromname,
$attachments=false)
{
$eol="\r\n";
$mime_boundary=md5(time());

# Common Headers
$headers .= "From: ".$fromname."<".$fromaddress.">".$eol;
$headers .= "Reply-To: ".$fromname."<".$fromaddress.">".$eol;
$headers .= "Return-Path: ".$fromname."<".$fromaddress.">".
$eol; // these two to set reply address
$headers .= "Message-ID: <".time()."-".$fromaddress.">".$eol;
$headers .= "X-Mailer: PHP v".phpversion().$eol; // These
two to avoid spam-filters

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

# Open the first part of the mail
$msg = "--".$mime_boundary.$eol;

$htmlalt_mime_boundary = $mime_boundary."_htmlalt"; //we must define
a different MIME boundary for this section
# Setup for text OR html -
$msg .= "Content-Type: multipart/alternative; boundary=\"".
$htmlalt_mime_boundary."\"".$eol.$eol;

# Text Version
$msg .= "--".$htmlalt_mime_boundary.$eol;
$msg .= "Content-Type: text/plain; charset=iso-8859-1".$eol;
$msg .= "Content-Transfer-Encoding: 8bit".$eol.$eol;
$msg .= strip_tags(str_replace("<br>", "\n", substr($body,
(strpos($body, "<body>")+6)))).$eol.$eol;

# HTML Version
$msg .= "--".$htmlalt_mime_boundary.$eol;
$msg .= "Content-Type: text/html; charset=iso-8859-1".$eol;
$msg .= "Content-Transfer-Encoding: 8bit".$eol.$eol;
$msg .= $body.$eol.$eol;

//close the html/plain text alternate portion
$msg .= "--".$htmlalt_mime_boundary."--".$eol.$eol;

if ($attachments !== false)
{
for($i=0; $i < count($attachments); $i++)
{
if (is_file($attachments[$i]["file"]))
{
# File for Attachment
$file_name = substr($attachments[$i]["file"],
(strrpos($attachments[$i]["file"], "/")+1));

$handle=fopen($attachments[$i]["file"], 'rb');
$f_contents=fread($handle, filesize($attachments[$i]
["file"]));
$f_contents=chunk_split(base64_encode($f_contents) ); //
Encode The Data For Transition using base64_encode();
$f_type=filetype($attachments[$i]["file"]);
fclose($handle);

# Attachment
$msg .= "--".$mime_boundary.$eol;
$msg .= "Content-Type: ".$attachments[$i]["content_type"].";
name=\"".$file_name."\"".$eol; // sometimes i have to send MS Word,
use 'msword' instead of 'pdf'
$msg .= "Content-Transfer-Encoding: base64".$eol;
$msg .= "Content-Description: ".$file_name.$eol;
$msg .= "Content-Disposition: attachment; filename=\"".
$file_name."\"".$eol.$eol; // !! This line needs TWO end of lines !!
IMPORTANT !!
$msg .= $f_contents.$eol.$eol;
}
}
}

# Finished
$msg .= "--".$mime_boundary."--".$eol.$eol; // finish with two
eol's for better security. see Injection.

# SEND THE EMAIL
ini_set(sendmail_from,$fromaddress); // the INI lines are to force
the From Address to be used !
$mail_sent = mail($to, $subject, $msg, $headers);

ini_restore(sendmail_from);

return $mail_sent;
}

  Réponse avec citation
Vieux 03/09/2007, 19h02   #2
Jerry Stuckle
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: PHP Mail gets blocked by spam filters

jason.m.ho@gmail.com wrote:
> Hello,
> I need to be able to send email in PHP without it getting filtered by
> spam filters. Gmail usually filters all email sent using the "mail()"
> function. I've looked on the forums, and am using the function below.
> However, it seems to display alot of the meta data inside the email
> itself. Is there something I'm doing wrong? Does anyone have any
> suggestions/example that will send a well-formed email (with all the
> meta data in tact)?
>
> Thanks in advance,
> Jason Ho
> Founder Clockspot.net
> http://www.clockspot.net
>


<code snipped>

Gmail (or any MTA) doesn't know if the mail comes from the mail()
function or something else. All it knows is what's in the mail.

Take a look at the source for an email which gets through Gmail and
compare them to the source of one which gets filtered. What's the
difference?

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
  Réponse avec citation
Vieux 03/09/2007, 19h29   #3
J.O. Aho
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: PHP Mail gets blocked by spam filters

jason.m.ho@gmail.com wrote:
> Hello,
> I need to be able to send email in PHP without it getting filtered by
> spam filters.


Avoid things that would make the mail to be classed as spam, like HTML tags
and false headers (copy headers from a mail client like outlook express).

Also see to that the sending server has a proper reverseDNS and isn't included
at some of the major blacklists.




--

//Aho
  Réponse avec citation
Vieux 03/09/2007, 22h01   #4
NC
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: PHP Mail gets blocked by spam filters

On Sep 3, 11:02 am, Jerry Stuckle <jstuck...@attglobal.net> wrote:
>
> Take a look at the source for an email which gets through Gmail and
> compare them to the source of one which gets filtered. What's the
> difference?


Additionally, make sure that the domain in the "From:" field and the
domain on which the SMTP server resides are the same (for example, if
you are sending mail from user@example.com, it should be sent through
an SMTP server in the *.example.com domain). Also, make sure that
your SMTP server is not blacklisted.

Cheers,
NC

  Réponse avec citation
Vieux 03/09/2007, 22h18   #5
Good Man
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: PHP Mail gets blocked by spam filters

"jason.m.ho@gmail.com" <jason.m.ho@gmail.com> wrote in
news:1188836731.304199.283080@57g2000hsv.googlegro ups.com:

> Hello,
> I need to be able to send email in PHP without it getting filtered by
> spam filters. Gmail usually filters all email sent using the "mail()"
> function. I've looked on the forums, and am using the function below.
> However, it seems to display alot of the meta data inside the email
> itself. Is there something I'm doing wrong? Does anyone have any
> suggestions/example that will send a well-formed email (with all the
> meta data in tact)?


it's definitely harder to do these days.

i've had several large networks (roadrunner, verizon) block all mail from
my server until i sent them a nice email explaining that my mail-list is
double opt-in, and that we are the only people on the IP.

having a reverse-lookup on the IP your mail originates from match the
domain you're sending from will be very ful.


  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 17h11.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,13283 seconds with 13 queries