PHP mail function does not send email to a valid account in the same domain

I use the mail function as follows:

mail($emailto, $subject, $body, $headers);
mail('askme@mysite.com', $subject.' / '.$emailto, $body, $headers);

The first is intended for the end user. The second instance is for me to keep records.

Sometimes the end user provides his email address, and sometimes his space.

  • When an email address is provided, the end user actually receives the email without any problems.
  • However, no emails are sent to askme@example.com in the case of EITHER - I also checked the spam folders.

In my / mail / new folder, I see many FILES created similarly to the ones below. The error is incorrect because askme@mysite.com is the VALID email address (setting up with Google for domains).

  Return-path: <>
  Envelope-to: myuserid@myhostingprovider.com
  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 myuserid@myhostingprovider.com; Mon, 28 Jun 2010 12:37:28 -0400
  X-Failed-Recipients: askme@mysite.com
  Auto-Submitted: auto-replied
  From: Mail Delivery System <Mailer-Daemon@myhostingprovider.com>
  To: myuserid@myhostingprovider.com
  Subject: Mail delivery failed: returning message to sender
  Message-Id: <EUNIQUEIDZ-7x@myhostingprovider.com>
  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:

    askme@mysite.com
      No Such User Here

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

  Return-path: <myuserid@myhostingprovider.com>
  Received: from nobody by myhostingprovider.com with local (Exim 4.69)
      (envelope-from <myuserid@myhostingprovider.com>)
      id UNIQUEIDV-6b
      for askme@mysite.com; Mon, 28 Jun 2010 12:37:28 -0400
  To: askme@mysite.com
  Subject: mysite.com: SUBJECT / enduser@gmail.com
  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 <askme@mysite.com>
  Message-Id: <EUNIQUEIDV-6b@myhostingprovider.com>
  Date: Mon, 28 Jun 2010 12:37:28 -0400
+3
source share
3 answers

Two things:

  • You should check to see if there is any remaining $emailtobefore the actual function call mail. You do not want PHP trying to send mail to an empty address.

  • askme@mysite.com , , - (mysite.com), , "" , - , Google Apps. (, sendmail) , "".

+5

(, , hotmail/gmail Outlook/Thunderbird)?

- .

- , - (, , ?).

0

If you use sendmail , go to the configuration file and using MX records to point to Google Apps like me do the following

sudo vim /etc/mail/sendmail.mc

add this:

FEATURE(`relay_based_on_MX')dnl

restart sending mail

sudo /etc/init.d/sendmail restart
0
source

Source: https://habr.com/ru/post/1752203/


All Articles