Page 1 of 1

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

Posted: Wed Sep 08, 2004 1:44 pm
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]

Posted: Wed Sep 08, 2004 1:52 pm
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?

Posted: Wed Sep 08, 2004 2:31 pm
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.