Current location: Hot Scripts Forums » Programming Languages » PHP » php mail apache and postfix issue


php mail apache and postfix issue

Reply
  #1 (permalink)  
Old 11-02-05, 03:41 PM
tgar2004 tgar2004 is offline
New Member
 
Join Date: Nov 2005
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Angry php mail apache and postfix issue

I am using the following code to allow a user to submit an e-mail form to a specified address. The code works fine, however, the mail is being rejected with the following error:

553 5.1.8 <apache@atsomehost.com>... Domain of sender address apache@atsomehost.com does not exist (in reply to MAIL FROM command))

Using the code below, how do instruct PHP to send e-mail from a valid e-mail account/domain?

-----------contact.php-------------------------------------------
<p><form method="post" action="sendeail.php">

<?php
$ipi = getenv("REMOTE_ADDR");
$httprefi = getenv ("HTTP_REFERER");
$httpagenti = getenv ("HTTP_USER_AGENT");
?>

<p>
<input type="hidden" name="ip" value="<?php echo $ipi ?>" />
<input type="hidden" name="httpref" value="<?php echo $httprefi ?>" />
<input type="hidden" name="httpagent" value="<?php echo $httpagenti ?>" />
</p>
<p><font size="2" face="Arial, Helvetica, sans-serif">Your Name: <br />
<input type="text" name="visitor" size="35" />
<br />
Your Email:<br />
<input type="text" name="visitormail" size="35" />
<br />
<br />
CC Yourself? No
<input name="ccopy" type="radio" value="ccno" />
Yes
<input checked="checked" name="ccopy" type="radio" value="ccyes" />
<br />
<br />
Send To:<br />
<select name="attn" size="1">
<option value=" Sales and Billing ">Sales and Billing </option>
<option value=" General Question ">General Question </option>
</select>
<br />
<br />
Mail Message: </font><br />
<textarea name="notes" rows="6" cols="40"></textarea>
<br />
<input type="submit" value="Send Mail" />
<br />
</p>
</form>

------- sendeail.php-----------------------------------------------
<?php

$myemail = "specific@email.com";
$ccx = "";

if(!$visitormail == "" && (!strstr($visitormail,"@") || !strstr($visitormail,".")))
{
echo "<h2>Use Back - Enter valid e-mail</h2>\n";
$badinput = "<h2>Feedback was NOT submitted</h2>\n";
}
if(empty($visitor) || empty($visitormail) || empty($notes )) {
echo "<h2>Use Back - fill in all fields</h2>\n";
}
echo $badinput;

$todayis = date("l, F j, Y, g:i a") ;

$attn = $attn . "(" . $ccopy . ")" ;
$subject = $attn;

$notes = stripcslashes($notes);

$message = " $todayis [EST] \n
Attention: $attn \n
Message: $notes \n
From: $visitor ($visitormail)\n
Additional Info : IP = $ip \n
Browser Info: $httpagent \n
Referral : $httpref \n
";

$from = "From: $visitormail\r\n";

if (($ccopy == "ccyes") && ($visitormail != ""))
mail($visitormail, $subject, $message, $from);

if ($myemail != "")
mail($myemail, $subject, $message, $from);

if ($ccx != "")
mail($ccx, $subject, $message, $from);

?>

<p align="center">
Date: <?php echo $todayis ?>
<br />
Thank You : <?php echo $visitor ?> ( <?php echo $visitormail ?> )
<br />

Attention: <?php echo $attn ?>
<br />
Message:<br />
<?php $notesout = str_replace("\r", "<br/>", $notes);
echo $notesout; ?>
<br />
<?php echo $ip ?> <a href="contact.php"> Next Page </a>


Thank you
Reply With Quote
  #2 (permalink)  
Old 11-03-05, 01:34 AM
nugensoftware's Avatar
nugensoftware nugensoftware is offline
Newbie Coder
 
Join Date: Oct 2005
Location: United States
Posts: 96
Thanks: 0
Thanked 0 Times in 0 Posts
This problem happens often with shared hosting. I would check the DNS configuration of your server at: http://www.dnsstuff.com/ for mistakes.

Otherwise you should move to SMTP verified mail sending. There are a lot of classes out there than you can easily incorporate into your script.

Mail() uses sendmail by default and causes issues like this because of spamming exploits in the past.

Code wise the only change i would make is in your headers.

From: $visitor ($visitormail)

to

From: $visitormail
__________________
Nugen Software Inc.
Lead Developer
www.nugensoftware.com

PHP HELP | MySQL HELP | xmlSYNC
Reply With Quote
  #3 (permalink)  
Old 11-03-05, 09:23 AM
tgar2004 tgar2004 is offline
New Member
 
Join Date: Nov 2005
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Apache and Postfix reside on the same server. The SMTP service works properly and is able to send e-mail to anyone.

When the form is submitted its sent as apache@gp2.hostname.com

I would like it to be sent from apache@hostname.com

Can this be done?
Reply With Quote
  #4 (permalink)  
Old 11-04-05, 01:32 AM
nugensoftware's Avatar
nugensoftware nugensoftware is offline
Newbie Coder
 
Join Date: Oct 2005
Location: United States
Posts: 96
Thanks: 0
Thanked 0 Times in 0 Posts
what SMTP server are you using in the php config?

If you are running on windows you can have multiple SMTP services (sendmail / exim etc.)

Verify that the default SMTP server is configured with inline options in your php.ini

I believe it is SMTP_path

for exim mine is set to /usr/sbin/exim -t as -t -d would make it wait for more information and hang.

by default php is configured for sendmail.
__________________
Nugen Software Inc.
Lead Developer
www.nugensoftware.com

PHP HELP | MySQL HELP | xmlSYNC
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump


All times are GMT -5. The time now is 06:18 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.