Reputation: 599
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.
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
Upvotes: 3
Views: 4181
Reputation: 811
If you are using sendmail go to the config file and using MX records to point to Google Apps like I do, do the following:
sudo vim /etc/mail/sendmail.mc
add this:
FEATURE(`relay_based_on_MX')dnl
restart send mail
sudo /etc/init.d/sendmail restart
Upvotes: 0
Reputation: 43794
Two things:
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.
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".
Upvotes: 6
Reputation: 41823
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?).
Upvotes: 0