'mail' function no delivery, "from" address same a

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
andy_west
Forum Newbie
Posts: 2
Joined: Tue Sep 07, 2004 3:20 pm
Location: Greenbrae, CA

'mail' function no delivery, "from" address same a

Post by andy_west »

Sami | Please use

Code: Select all

and

Code: Select all

tags where approriate when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color][/size]


Hi,

When I use the php 'mail' function in our application to send mail to a "to" address that is the same as the "from" address, the mail never gets delivered.  Yet, when the two addresses are different the mail goes through.  It doesn't matter what I put for values of return path, sender or reply to (in case you're wondering).  The 'mail' function returns successfully in both instances.

Any idea how I can send to a "to" address using the same "from" address?  This is important for customer testing using our application.


Here's the two scenarios:
==========================

Does not get delivered (same "from" and "to" addresses):
-------------------------

Code: Select all

<?php
$to = "andy@ridgecrestmarketing.com";
$from = "andy@ridgecrestmarketing.com";
$body = "test message";
$subject = "test subject";

  $head  = '';
  $head  .= "Content-Type: text/plain \n";
  $head  .= "Date: ". date('r'). " \n";
  $head  .= "Return-Path: $from \n";
  $head  .= "From: $from \n"; 
  $head  .= "Sender: $from \n"; 
  $head  .= "Reply-To: $from \n";
  $head  .= "X-Sender: $from \n";
  $head  .= "X-Priority: 3 \n"; 
  $head .= "X-Mailer: PHP/" . phpversion(); 

  mail($to, $subject, $body, $head);
?>

mail gets delivered (different "from" and "to" addresses)
-------------------------------------

exactly as above, but

Code: Select all

$from = "[any valid email address different than the $to address above]
Sami | Please use

Code: Select all

and

Code: Select all

tags where approriate when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color][/size]
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

it's possible your server is set to not send email to itself, or rather from user x to themselves. What about creating a seperate email account on the server for this testing?
andy_west
Forum Newbie
Posts: 2
Joined: Tue Sep 07, 2004 3:20 pm
Location: Greenbrae, CA

Post by andy_west »

Thanks.

I've already tried "from" and "to" email accounts that are set up on the server (if you happen to mean email accounts using our domain, 'ridgecrestsurveys.com', that is on the same local network as the email server's domain, 'reservehostserver.net').

I'll put your idea about server settings down as something to check with our email server person. When I use MS Outlook I'm able to successfully send using the same from and to addresses, but it's also SMTP and a Windows app, instead of from our PHP web app.
Post Reply