The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
sendmail only sends emails to its own domain jjwood64 AIX 3 01-24-2008 12:27 PM
mail command woth Postfix piltrafa UNIX for Dummies Questions & Answers 1 12-18-2007 08:34 AM
Configuring my PostFix Mail Server fundidor UNIX for Dummies Questions & Answers 4 06-01-2004 09:43 AM
Cron Sends mail to root on completion of job. skotapal UNIX for Dummies Questions & Answers 1 04-25-2003 05:27 PM
Linux mail servers benchmarks (Qmail, Sendmail,Postfix) cipango News, Links, Events and Announcements 0 07-26-2002 02:30 PM

 
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 03-05-2008
boopfm523 boopfm523 is offline
Registered User
  
 

Join Date: Mar 2008
Posts: 1
PHP Script that sends mail - Postfix breaks it

I have a PHP Script that works perfectly on a server that uses Sendmail. However I tried to port it to a new server that has the Postfix to Sendmail compatibility interface, and it doesn't work properly.

The php.ini file has the path for sendmail on both servers set to: /usr/sbin/sendmail -t -i

Here is the PHP function.
Code:
function send_email($from, $to, $subject, $textMsg, $htmlMsg = ''){
 $from = stripslashes($from);
 $subject = stripslashes($subject);
 $textMsg = stripslashes($textMsg);
 if (eregi("\r",$from) || eregi("\n",$from)){
    die("Sorry, the from addess is invalid.  If you feel you have gotten this message in error, please contact the system administrator.");
 }
 if (eregi("\r",$to) || eregi("\n",$to)){
    die("Sorry, the to addess is invalid.  If you feel you have gotten this message in error, please contact the system administrator.");
 }
 if (eregi("\r",$subject) || eregi("\n",$subject)){
    die("Sorry, the subject is invalid.  If you feel you have gotten this message in error, please contact the system administrator.");
 }
  
 if($htmlMsg > ''){
   $body = "\r\n--gc0p4Jq0M2Yt08j34c0p\r\n" .
           "Content-Type: text/plain; charset=us-ascii; format=flowed\r\n" .
           "Content-Transfer-Encoding: 7bit\r\n\r\n" .
           "$textMsg\r\n\r\n" .
           "--gc0p4Jq0M2Yt08j34c0p\r\n" .
           "Content-Type: text/html; charset=us-ascii;\r\n" .
           "Content-Transfer-Encoding: 7bit\r\n\r\n" .
           "$htmlMsg\r\n";
 }else{
    $body = "\r\n--gc0p4Jq0M2Yt08j34c0p\r\n" .
           "Content-Type: text/plain; charset=us-ascii; format=flowed\r\n" .
           "Content-Transfer-Encoding: 7bit\r\n\r\n" .
            "$textMsg\r\n\r\n";
 }
 $hdr = "Mime-Version: 1.0\r\n" .
           "From: $from\r\n" .
           "Reply-To: $from\r\n" .
           "Content-Type: multipart/alternative; boundary=\"gc0p4Jq0M2Yt08j34c0p\"\r\n" .
           "Date: " . date('r') . "\r\n";

 mail($to, $subject, $body, $hdr) ;
}
Everything gets shifted or something in the email went it is sent off the Postfix server. The from address becomes blank when I receive it. Then the body looks something like this:
=========
From: jeff@emailhere1.com

Reply-To: jeff@emailhere1.com

Content-Type: multipart/alternative; boundary="gc0p4Jq0M2Yt08j34c0p"

Date: Tue, 04 Mar 2008 21:37:21 -0500

Message-Id: <20080305023721.169903A415D@serverhostname.com>
X-Spam: [F=0.6145044964; B=0.500(0); CM=0.500; MH=0.500(2008030474); R=0.600(10824171516); S=0.515(2008012801); SS=0.500; SC=none]
X-MAIL-FROM: <apache@serverhostname.com>
X-SOURCE-IP: [99.999.999.999]
X-AnalysisOut: [v=1.0 c=0 a=PJwPNPI7AAAA:8 a=5tm0iYomoMYUE1dKbXIA:9 a=ZnIH]
X-AnalysisOut: [FGK1kxZMqYugtdp_urtXkEMA:4 a=TZyYahp_f9YA:10 a=YH6K3Mh3ZBA]
X-AnalysisOut: [A:10]
Return-Path: apache@serverhostname.com
X-OriginalArrivalTime: 05 Mar 2008 02:37:21.0739 (UTC) FILETIME=[D69DC9B0:01C87E69]




--gc0p4Jq0M2Yt08j34c0p

Content-Type: text/plain; charset=us-ascii; format=flowed

Content-Transfer-Encoding: 7bit




email body is here
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 08:40 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0