views:

40

answers:

2

I'm using the mail function as follows:

mail($emailto, $subject, $body, $headers);
mail('[email protected]', $subject.' / '.$emailto, $body, $headers);

The first is intended for the enduser. The second copy is for me for record keeping purposes.

Soometimes the enduser specifies their email address, other times its blank.

  1. When an email address is specified, the end user actuallys gets the email without any problem
  2. However, no email gets sent to [email protected] in EITHER case - I've checked the spam folders as well.

In my /mail/new folder I see many FILES created similar to the below. The error is incorrect as [email protected] is a VALID email address (setup using google for domains).

  Return-path: <>
  Envelope-to: [email protected]
  Delivery-date: Mon, 28 Jun 2010 12:37:28 -0400
  Received: from mailnull by myhostingprovider.com with local (Exim 4.69)
      id UNIQUEIDZ-7x
      for [email protected]; Mon, 28 Jun 2010 12:37:28 -0400
  X-Failed-Recipients: [email protected]
  Auto-Submitted: auto-replied
  From: Mail Delivery System <[email protected]>
  To: [email protected]
  Subject: Mail delivery failed: returning message to sender
  Message-Id: <[email protected]>
  Date: Mon, 28 Jun 2010 12:37:28 -0400

  This message was created automatically by mail delivery software.

  A message that you sent could not be delivered to one or more of its
  recipients. This is a permanent error. The following address(es) failed:

    [email protected]
      No Such User Here

  ------ This is a copy of the message, including all the headers. ------

  Return-path: <[email protected]>
  Received: from nobody by myhostingprovider.com with local (Exim 4.69)
      (envelope-from <[email protected]>)
      id UNIQUEIDV-6b
      for [email protected]; Mon, 28 Jun 2010 12:37:28 -0400
  To: [email protected]
  Subject: mysite.com: SUBJECT / [email protected]
  X-PHP-Script: www.mysite.com/mysitescript.php for IPADDRESS
  MIME-Version: 1.0
  Content-type: text/html; charset=UTF-8
  From: mysite.com Service <[email protected]>
  Message-Id: <[email protected]>
  Date: Mon, 28 Jun 2010 12:37:28 -0400
A: 

Can you send an email to that address using a normal email client (web one like hotmail/gmail or Outlook/Thunderbird)?

If you can't - your email account isn't setup correctly.

If you can - your email account is setup to ignore your domain or something similar (perhaps a spamfilter pretending the user does not exist?).

Graphain
A: 

Two things:

  1. You should check to see if $emailto is blank before actually calling the mail function. You don't want PHP to try to send mail to a blank address.

  2. Your problem with [email protected] not being delivered is probably a result of your local website host (mysite.com) trying to deliver mail to what it considers a "local" address - since it's on the same domain, when in reality that email exists out in Google Apps. Your mail server (like postfix or sendmail) should have a setting to disable this "shortcut".

philfreo
............. yes... that second point sounds like it... I'm on a shared server hosting - how/where do i look for this "option"? The provider has given us cpanel access as well (besides a shell account)
Dave
try cPanel -> MX Entry -> Email Routing -> Remote Mail Exchanger. don't forget to upvote helpful answers and mark one correct :)
philfreo