[KLUG Members] php mail problem (source code)

Russell Dillenburg members@kalamazoolinux.org
Sat, 17 Aug 2002 20:54:19 -0700 (PDT)


--0-1173822830-1029642859=:6096
Content-Type: text/plain; charset=us-ascii


Here's a copy of the class file 
// contact_.php
class contactme {var $ip;var $admin_mail = "rdillenbu@yahoo.com";   function contactme ($ip) {      $this->ip = $ip;   }   function _sendMail($formname, $formemail, $formcomments, $formsubject) {      $headers  = "From: \"$formname\"<$formemail>\n";      $headers .= "Date: " .date("D, j M Y G:i:s Z"). "\n";      if ($formname && $formemail && $formcomments)   {         $mStrmail = "$formcomments";         $mSend = mail ($this->admin_mail, $formsubject, $mStrmail, $headers);         if ($mSend) {            include ("http://russell.knightec.net/contact/confirm.php?comments=$formcomments&name=$formname");            exit;         } else {            include ("http://russell.knightec.net/contact/error.php?mSend=$mSend");            exit;         }      } else            include ("http://russell.knightec.net/contact/user_error.html");            exit;  }}

I'm instantiating it in this file:

//contact.php
   include("../contact_.php");

   $contact = new contactme ($REMOTE_ADDR);

   if ( $SUBMIT == "Send" ) {

      $contact->_sendMail($name, $email, $comments, $subject);

   }

 Todd Pillars wrote: what version of php? and are you cc or Bcc to anyone when you mail()? also make sure all your php.ini params are correct - go through line by line - specifically check about line 310-311 for your sendmail optionsright now your script is running as apache and is defaulting to apache@hercules (localhost) make sure your script is sending a fully qualified domain. ie webmaster@your.com for the From: field which in turn will default to the Return-to field. and check http://www.php.net/manual/en/function.mail.php to catch all the things I missed : ) Todd-----Original Message-----
From: members-admin@kalamazoolinux.org [mailto:members-admin@kalamazoolinux.org]On Behalf Of Russell Dillenburg
Sent: Saturday, August 17, 2002 10:55 PM
To: members@kalamazoolinux.org
Subject: [KLUG Members] php mail problem


Hi,

My server seems to be having trouble sending emails.  I noticed when I trie wat d emailing in one of my php scripts, http://russell.knightec.net/contact/.  I included below what gets bounced back to me.  

If you were to try and send a message using that it'll just come back to from mail daemon.  I had this working before, but forget how, or what I did.  Maybe something about my hostname/domain?  I am using the mail function in php to send.  This has worked fine in the past (old server).  

Thanks for any help!

Russell Dillenburg

 

>From Mail Delivery Subsystem Sat Aug 17 19:46:00 2002X-Apparently-To:rdillenbu@yahoo.com via -40.-120.-81.80; 17 Aug 2002 19:51:16 -0700 (PDT)Return-Path:<>Received:from 209.68.1.157 (HELO gwind.pair.com) (209.68.1.157) by mta624.mail.yahoo.com with SMTP; 17 Aug 2002 19:51:16 -0700 (PDT)Received:(qmail 1411 invoked by uid 3036); 18 Aug 2002 02:51:15 -0000Delivered-To:jfd-dillenburg:org-russell@dillenburg.orgReceived:(qmail 1408 invoked from network); 18 Aug 2002 02:51:14 -0000Received:from 12-251-0-48.client.attbi.com (HELO hercules) (12.251.0.48) by gwind.pair.com with SMTP; 18 Aug 2002 02:51:14 -0000Received:from localhost (localhost) by hercules (8.11.6/8.11.6) id g7I2k0B09115; Sat, 17 Aug 2002 21:46:00 -0500Date:Sat, 17 Aug 2002 21:46:00 -0500From:"Mail Delivery Subsystem" <MAILER-DAEMON@hercules> | This is Spam | Add to Address BookMessage-Id:<200208180246.g7I2k0B09115@hercules>To:apache@herculesMIME-Version:1.0Content-Type:multipart/report; report-type=delivery-status; boundary="g7I2k0B09115.1029638760/hercules"Subject:Returned mail: see transcript for detailsAuto-Submitted:auto-generated (failure)Content-Length:625       


The original message was received at Sat, 17 Aug 2002 21:46:00 -0500from apache@localhost   ----- The following addresses had permanent fatal errors -----rdillenbu@yahoo.com    (reason: 501 Syntax error in parameters or arguments)   ----- Transcript of session follows -----... while talking to mx1.mail.yahoo.com.:>>> MAIL From:<apache@hercules> SIZE=159<<< 501 Syntax error in parameters or arguments501 5.6.0 Data format error


Message/delivery-status 
Reporting-MTA: dns; herculesArrival-Date: Sat, 17 Aug 2002 21:46:00 -0500Final-Recipient: RFC822; rdillenbu@yahoo.comAction: failedStatus: 5.5.2Diagnostic-Code: SMTP; 501 Syntax error in parameters or argumentsLast-Attempt-Date: Sat, 17 Aug 2002 21:46:00 -0500


Forwarded Message [ Save to my Yahoo! Briefcase  |  Download File ] Return-Path:<apache>Received:(from apache@localhost) by hercules (8.11.6/8.11.6) id g7I2k0C09112; Sat, 17 Aug 2002 21:46:00 -0500Message-Id:<200208180246.g7I2k0C09112@hercules>To:rdillenbu@yahoo.comSubject:Message from websiteFrom:"testing" <russell@test.dillenburg.org>Date:Sat, 17 Aug 2002 21:45:59 -18000

testing stuff here




--
Russell Dillenburg
"The software business is binary, you're either a 1 or a 0--alive or dead."



---------------------------------
Do You Yahoo!?
HotJobs, a Yahoo! service - Search Thousands of New Jobs



--
Russell Dillenburg
"The software business is binary, you're either a 1 or a 0--alive or dead."



---------------------------------
Do You Yahoo!?
HotJobs, a Yahoo! service - Search Thousands of New Jobs
--0-1173822830-1029642859=:6096
Content-Type: text/html; charset=us-ascii

<P>Here's a copy of the class file&nbsp;<PRE>// contact_.php<BR>class contactme {
var $ip;
var $admin_mail = "rdillenbu@yahoo.com";
   function contactme ($ip) {
      $this-&gt;ip = $ip;
   }
   function _sendMail($formname, $formemail, $formcomments, $formsubject) {
      $headers  = "From: \"$formname\"&lt;$formemail&gt;\n";
      $headers .= "Date: " .date("D, j M Y G:i:s Z"). "\n";
      if ($formname &amp;&amp; $formemail &amp;&amp; $formcomments)   {
         $mStrmail = "$formcomments";
         $mSend = mail ($this-&gt;admin_mail, $formsubject, $mStrmail, $headers);
         if ($mSend) {
            include ("http://russell.knightec.net/contact/confirm.php?comments=$formcomments&amp;name=$formname");
            exit;
         } else {
            include ("http://russell.knightec.net/contact/error.php?mSend=$mSend");
            exit;
         }
      } else
            include ("http://russell.knightec.net/contact/user_error.html");
            exit;
  }
}
</PRE>
<P>I'm instantiating it in this file:</P><PRE>//contact.php<BR>&nbsp;&nbsp; include("../contact_.php");</PRE><PRE>&nbsp;&nbsp; $contact = new contactme ($REMOTE_ADDR);</PRE><PRE>&nbsp;&nbsp; if ( $SUBMIT == "Send" ) {</PRE><PRE>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $contact-&gt;_sendMail($name, $email, $comments, $subject);</PRE><PRE>&nbsp;&nbsp; }</PRE>
<P>&nbsp;<B><I>Todd Pillars <KAZOOT@CHARTERMI.NET></I></B>wrote: 
<BLOCKQUOTE style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #1010ff 2px solid">
<META content="MSHTML 6.00.2600.0" name=GENERATOR>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN class=039521703-18082002>what version of php? and are you cc or Bcc to anyone when you mail()?</SPAN></FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN class=039521703-18082002></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN class=039521703-18082002>also make sure all your php.ini params are correct - go through line by line - specifically check about line 310-311 for your sendmail options</SPAN></FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN class=039521703-18082002>right now your script is running as apache and is defaulting to <A href="mailto:apache@hercules">apache@hercules</A>&nbsp;(localhost) make sure your script is sending a fully qualified domain. ie <A href="mailto:webmaster@your.com">webmaster@your.com</A>&nbsp;for the From: field which in turn will default to the Return-to field.</SPAN></FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN class=039521703-18082002></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN class=039521703-18082002>and check <A href="http://www.php.net/manual/en/function.mail.php">http://www.php.net/manual/en/function.mail.php</A>&nbsp;to catch all the things I missed : )</SPAN></FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN class=039521703-18082002></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN class=039521703-18082002>Todd</SPAN></FONT></DIV>
<BLOCKQUOTE>
<DIV class=OutlookMessageHeader dir=ltr align=left><FONT face=Tahoma size=2>-----Original Message-----<BR><B>From:</B> members-admin@kalamazoolinux.org [mailto:members-admin@kalamazoolinux.org]<B>On Behalf Of </B>Russell Dillenburg<BR><B>Sent:</B> Saturday, August 17, 2002 10:55 PM<BR><B>To:</B> members@kalamazoolinux.org<BR><B>Subject:</B> [KLUG Members] php mail problem<BR><BR></FONT></DIV>
<P>Hi,</P>
<P>My server seems to be having trouble sending emails.&nbsp; I noticed when I trie<SPAN class=039521703-18082002><FONT face=Arial color=#0000ff size=2>&nbsp;wat&nbsp;</FONT></SPAN>d emailing in one of my php scripts, <A href="http://russell.knightec.net/contact/">http://russell.knightec.net/contact/</A>.&nbsp; I included below what gets bounced back to me.&nbsp; </P>
<P>If you were to try and send a message using that it'll just come back to from mail daemon.&nbsp; I had this working before, but forget how, or what I did.&nbsp; Maybe something about my hostname/domain?&nbsp;&nbsp;I am using the mail function in php to send.&nbsp; This has worked fine in the past (old server).&nbsp; </P>
<P>Thanks for any help!</P>
<P>Russell Dillenburg</P>
<P><FONT face=Arial color=#0000ff size=2></FONT>&nbsp;</P>
<P>
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
<TBODY>
<TR>
<TD>
<TABLE cellSpacing=0 cellPadding=3 width="100%" border=0>
<TBODY>
<TR vAlign=top>
<TR class=bge width="100%">
<TD align=left colSpan=2>From Mail Delivery Subsystem Sat Aug 17 19:46:00 2002</TD></TR>
<TR class=bge>
<TD vAlign=top noWrap align=right><B><SMALL><FONT size=1>X-Apparently-To:</FONT></SMALL></B></TD>
<TD width="100%"><SMALL><FONT size=1>rdillenbu@yahoo.com via -40.-120.-81.80; 17 Aug 2002 19:51:16 -0700 (PDT)</FONT></SMALL></TD></TR>
<TR class=bge>
<TD vAlign=top noWrap align=right><B><SMALL><FONT size=1>Return-Path:</FONT></SMALL></B></TD>
<TD width="100%"><SMALL><FONT size=1>&lt;&gt;</FONT></SMALL></TD></TR>
<TR class=bge>
<TD vAlign=top noWrap align=right><B><SMALL><FONT size=1>Received:</FONT></SMALL></B></TD>
<TD width="100%"><SMALL><FONT size=1>from 209.68.1.157 (HELO gwind.pair.com) (209.68.1.157) by mta624.mail.yahoo.com with SMTP; 17 Aug 2002 19:51:16 -0700 (PDT)</FONT></SMALL></TD></TR>
<TR class=bge>
<TD vAlign=top noWrap align=right><B><SMALL><FONT size=1>Received:</FONT></SMALL></B></TD>
<TD width="100%"><SMALL><FONT size=1>(qmail 1411 invoked by uid 3036); 18 Aug 2002 02:51:15 -0000</FONT></SMALL></TD></TR>
<TR class=bge>
<TD vAlign=top noWrap align=right><B><SMALL><FONT size=1>Delivered-To:</FONT></SMALL></B></TD>
<TD width="100%"><SMALL><FONT size=1>jfd-dillenburg:org-russell@dillenburg.org</FONT></SMALL></TD></TR>
<TR class=bge>
<TD vAlign=top noWrap align=right><B><SMALL><FONT size=1>Received:</FONT></SMALL></B></TD>
<TD width="100%"><SMALL><FONT size=1>(qmail 1408 invoked from network); 18 Aug 2002 02:51:14 -0000</FONT></SMALL></TD></TR>
<TR class=bge>
<TD vAlign=top noWrap align=right><B><SMALL><FONT size=1>Received:</FONT></SMALL></B></TD>
<TD width="100%"><SMALL><FONT size=1>from 12-251-0-48.client.attbi.com (HELO hercules) (12.251.0.48) by gwind.pair.com with SMTP; 18 Aug 2002 02:51:14 -0000</FONT></SMALL></TD></TR>
<TR class=bge>
<TD vAlign=top noWrap align=right><B><SMALL><FONT size=1>Received:</FONT></SMALL></B></TD>
<TD width="100%"><SMALL><FONT size=1>from localhost (localhost) by hercules (8.11.6/8.11.6) id g7I2k0B09115; Sat, 17 Aug 2002 21:46:00 -0500</FONT></SMALL></TD></TR>
<TR class=bge>
<TD vAlign=top noWrap align=right><B><SMALL><FONT size=1>Date:</FONT></SMALL></B></TD>
<TD width="100%"><SMALL><FONT size=1>Sat, 17 Aug 2002 21:46:00 -0500</FONT></SMALL></TD></TR>
<TR class=bge>
<TD vAlign=top noWrap align=right><B><SMALL><FONT size=1>From:</FONT></SMALL></B></TD>
<TD width="100%"><SMALL><FONT size=1>"Mail Delivery Subsystem" &lt;MAILER-DAEMON@hercules&gt;&nbsp;|&nbsp;<B><A href="http://us.f135.mail.yahoo.com/ym/BlockSender?MessRet=1&amp;.crumb=sjeyxbO5Hsl&amp;SP=Yes&amp;NE=mailer-daemon@hercules&amp;box=Inbox&amp;MsgId=1260_2230919_4729_1327_625_0_16618&amp;inc=&amp;num=&amp;Search=&amp;YY=41442&amp;order=down&amp;sort=date&amp;pos=0"><SMALL>This is Spam</SMALL></A></B>&nbsp;|&nbsp;<B><A href="javascript:document.frmAddAddrs.submit()"><SMALL>Add to Address Book</SMALL></A></B></FONT></SMALL></TD></TR>
<TR class=bge>
<TD vAlign=top noWrap align=right><B><SMALL>Message-Id:</SMALL></B></TD>
<TD width="100%"><SMALL>&lt;200208180246.g7I2k0B09115@hercules&gt;</SMALL></TD></TR>
<TR class=bge>
<TD vAlign=top noWrap align=right><B><SMALL>To:</SMALL></B></TD>
<TD width="100%"><SMALL>apache@hercules</SMALL></TD></TR>
<TR class=bge>
<TD vAlign=top noWrap align=right><B><SMALL>MIME-Version:</SMALL></B></TD>
<TD width="100%"><SMALL>1.0</SMALL></TD></TR>
<TR class=bge>
<TD vAlign=top noWrap align=right><B><SMALL>Content-Type:</SMALL></B></TD>
<TD width="100%"><SMALL>multipart/report; report-type=delivery-status; boundary="g7I2k0B09115.1029638760/hercules"</SMALL></TD></TR>
<TR class=bge>
<TD vAlign=top noWrap align=right><B><SMALL>Subject:</SMALL></B></TD>
<TD width="100%"><SMALL>Returned mail: see transcript for details</SMALL></TD></TR>
<TR class=bge>
<TD vAlign=top noWrap align=right><B><SMALL>Auto-Submitted:</SMALL></B></TD>
<TD width="100%"><SMALL>auto-generated (failure)</SMALL></TD></TR>
<TR class=bge>
<TD vAlign=top noWrap align=right><B><SMALL>Content-Length:</SMALL></B></TD>
<TD width="100%"><SMALL>625</SMALL></TD></TR></TBODY></TABLE></TD>
<TD vAlign=top bgColor=#eeeeee>
<FORM name=frmAddAddrs action=http://address.mail.yahoo.com/yab/us?v=YM&amp;cmode=1&amp;Lang=us method=post>
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
<TBODY>
<TR vAlign=top>
<TD align=left bgColor=#eeeeee><FONT face=Arial size=-1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </FONT></TD></TR></TBODY></TABLE></FORM></TD></TR></TBODY></TABLE><BR></P>
<DIV id=message><PRE><TT>The original message was received at Sat, 17 Aug 2002 21:46:00 -0500
from apache@localhost

   ----- The following addresses had permanent fatal errors -----
<A href="http://us.f135.mail.yahoo.com/ym/Compose?To=rdillenbu@yahoo.com&amp;YY=41442&amp;order=down&amp;sort=date&amp;pos=0">rdillenbu@yahoo.com</A>
    (reason: 501 Syntax error in parameters or arguments)

   ----- Transcript of session follows -----
... while talking to mx1.mail.yahoo.com.:
&gt;&gt;&gt; MAIL From:&lt;apache@hercules&gt; SIZE=159
&lt;&lt;&lt; 501 Syntax error in parameters or arguments
501 5.6.0 Data format error
</TT></PRE><BR><BR>
<TABLE cellSpacing=0 cellPadding=4 width="100%" border=0>
<TBODY>
<TR class=heada>
<TD><B>Message/delivery-status</B> </TD></TR></TBODY></TABLE><PRE><FONT size=+0>Reporting-MTA: dns; hercules
Arrival-Date: Sat, 17 Aug 2002 21:46:00 -0500

Final-Recipient: RFC822; <A href="http://us.f135.mail.yahoo.com/ym/Compose?To=rdillenbu@yahoo.com&amp;YY=41442&amp;order=down&amp;sort=date&amp;pos=0">rdillenbu@yahoo.com</A>
Action: failed
Status: 5.5.2
Diagnostic-Code: SMTP; 501 Syntax error in parameters or arguments
Last-Attempt-Date: Sat, 17 Aug 2002 21:46:00 -0500
</FONT></PRE><BR><BR>
<TABLE cellSpacing=0 cellPadding=4 width="100%" border=0>
<TBODY>
<TR class=heada>
<TD><B>Forwarded Message</B> [ <A href="http://us.f135.mail.yahoo.com/ym/ShowLetter/file.txt?box=Inbox&amp;MsgId=1260_2230919_4729_1327_625_0_16618&amp;bodyPart=3.TEXT&amp;filename=file.txt&amp;Briefcase=1&amp;tnef=&amp;YY=41442&amp;order=down&amp;sort=date&amp;pos=0">Save to my Yahoo! Briefcase</A> &nbsp;|&nbsp; <A href="http://us.f135.mail.yahoo.com/ym/ShowLetter/file.txt?box=Inbox&amp;MsgId=1260_2230919_4729_1327_625_0_16618&amp;bodyPart=3.TEXT&amp;filename=file.txt&amp;download=1&amp;YY=41442&amp;order=down&amp;sort=date&amp;pos=0">Download File</A> ] </TD></TR></TBODY></TABLE>
<TABLE cellSpacing=0 cellPadding=3 border=0>
<TBODY>
<TR class=bge>
<TD vAlign=top noWrap align=right><B><SMALL><FONT face=Verdana size=1>Return-Path:</FONT></SMALL></B></TD>
<TD width="100%"><SMALL><FONT face=Verdana size=1>&lt;apache&gt;</FONT></SMALL></TD></TR>
<TR class=bge>
<TD vAlign=top noWrap align=right><B><SMALL><FONT face=Verdana size=1>Received:</FONT></SMALL></B></TD>
<TD width="100%"><SMALL><FONT face=Verdana size=1>(from apache@localhost) by hercules (8.11.6/8.11.6) id g7I2k0C09112; Sat, 17 Aug 2002 21:46:00 -0500</FONT></SMALL></TD></TR>
<TR class=bge>
<TD vAlign=top noWrap align=right><B><SMALL><FONT face=Verdana size=1>Message-Id:</FONT></SMALL></B></TD>
<TD width="100%"><SMALL><FONT face=Verdana size=1>&lt;200208180246.g7I2k0C09112@hercules&gt;</FONT></SMALL></TD></TR>
<TR class=bge>
<TD vAlign=top noWrap align=right><B><SMALL><FONT face=Verdana size=1>To:</FONT></SMALL></B></TD>
<TD width="100%"><SMALL><FONT face=Verdana size=1>rdillenbu@yahoo.com</FONT></SMALL></TD></TR>
<TR class=bge>
<TD vAlign=top noWrap align=right><B><SMALL><FONT face=Verdana size=1>Subject:</FONT></SMALL></B></TD>
<TD width="100%"><SMALL><FONT face=Verdana size=1>Message from website</FONT></SMALL></TD></TR>
<TR class=bge>
<TD vAlign=top noWrap align=right><B><SMALL><FONT face=Verdana size=1>From:</FONT></SMALL></B></TD>
<TD width="100%"><SMALL><FONT face=Verdana size=1>"testing" &lt;russell@test.dillenburg.org&gt;</FONT></SMALL></TD></TR>
<TR class=bge>
<TD vAlign=top noWrap align=right><B><SMALL><FONT face=Verdana size=1>Date:</FONT></SMALL></B></TD>
<TD width="100%"><SMALL><FONT face=Verdana size=1>Sat, 17 Aug 2002 21:45:59 -18000</FONT></SMALL></TD></TR></TBODY></TABLE><BR><PRE><TT>
testing stuff here
</TT></PRE></DIV><BR><BR>
<TABLE width="67%" border=0>
<TBODY>
<TR>
<TD width="50%">
<P><A href="http://12.251.0.48/"><IMG src="http://12.251.0.48/icons/Ysignature.gif" border=0 NOSEND="1"></A><BR>--<BR>Russell Dillenburg<BR><EM>"The software business is binary, you're either a 1 or a 0--alive or dead."</EM></P></TD></TR></TBODY></TABLE>
<P><BR>
<HR SIZE=1>
<B>Do You Yahoo!?</B><BR><A href="http://rd.yahoo.com/careers/mailsig/new/*http://www.hotjobs.com">HotJobs, a Yahoo! service</A> - Search Thousands of New Jobs</BLOCKQUOTE></BLOCKQUOTE><BR><BR><TABLE width="67%" border=0>
<TBODY>
<TR>
<TD width="50%">
<P><A href="http://12.251.0.48/"><IMG src="http://12.251.0.48/icons/Ysignature.gif" border=0></A><BR>--<BR>Russell Dillenburg<BR><EM>"The software business is binary, you're either a 1 or a 0--alive or dead."</EM></P></TD></TR></TBODY></TABLE><p><br><hr size=1><b>Do You Yahoo!?</b><br>
<a href="http://rd.yahoo.com/careers/mailsig/new/*http://www.hotjobs.com">HotJobs, a Yahoo! service</a> - Search Thousands of New Jobs
--0-1173822830-1029642859=:6096--