Function mail() PHP not working. I can't sending email


#1

I can’t sending email in WP and PHP applications.


#2

You could check if port 25 open. EE uses port 25 to send mails via postfix. Some providers like google cloud block port 25 to prevent spamming. You can also try using a SMTP plugin in the wordpress site and check if the mails are being sent.


#3

Yeah it’s best to use SMTP relay plugin. I use mailgun.com to relay my emails.


#4

Agree with Cim. I have tried many such solutions and my personal Fave is Sendgrid and “WP Mail SMTP by WPForms” plugin. Easy for simplicity, just install it, choose Sendgrid (after you get account) and paste in API. Done. There are no settings to get wrong. Good to install a mail log plugin too.


#5

sendmail: RCPT TO:contato@site.com.br (451 4.3.0 contato@site.com.br: Temporary lookup failure)


#6

^_^[www-data@site.com.br:~/htdocs]$ php -r ‘mail(“contato@site.com.br”, “Hello Human”, “Hello from EasyEngine!”);’

sendmail: RCPT TO:contato@site.com.br (451 4.3.0 contato@site.com.br: Temporary lookup failure)


#7
php -r 'mail("contato@site.com.br", "Hello Human", "Hello from EasyEngine!");'
sendmail: RCPT TO:<contato@site.com.br> (451 4.3.0 <contato@site.com.br>: Temporary lookup failure) 

#8

I send e-mail and display this: Temporary lookup failure.


#9

Sorry, my english is bad.


#10

I’m have same error


#11

If you change the email to another, for example, contact@gmail.com, it works. It does not send email with the same domain, example contact@site.com.br


#12

I’ve got the same issue here with all the same symptoms. Did you find a solution to this problem?


#13

Yeah it’s actually a bug in V4, related to V4 logging email errors

Here’s where I got so far. Standard V4 installation installs Postfix docker that is missing /etc/aliases file. Once that is fixed, the issue becomes between dockers it seems.
I don’t know how to fix it yet (still googling) but it seems that postfix docker resolves domain.com as the nginx docker. So all the emails works except from the same domain.

After a few hours fixing postfix docker I got as far as getting this error
Jan 24 12:19:59 ip-xxxxxxx website.com/smtpd[223]: NOQUEUE: reject: RCPT from websitecom_php_1.website.com[172.20.0.3]: 550 5.1.1 info@website.com: Recipient address rejected: User unknown in local recipient table; from=info@website.com to=info@website.com proto=SMTP helo=


#14

For WP I just use https://www.mailgun.com/ to handle my emails; it’s free (for 10k emails/month) and your emails will never end up in someone’s spam folder on accident (in my experience anyway.) – actually you’ll be informed if an email you sent went to spam instead of inbox.

You can also use it for any other application type on your server, I’m just saying to config it with WP takes only 5 minutes or less, they’ve got a plugin that handles it all. But even if you wanted to do it all manually, it works so simply with PHP and a lot of other languages too.

I have no affiliation with them. Just saying, really useful service. Note: If you’re currently using something like O365 or GSuite, or basically any email system for your normal incoming/outgoing email, obviously don’t configure mailgun to run on your root domain – it’s not supposed to take over your email system. You don’t get user inboxes and things like that. It is simply for sending out emails.

Instead, during the setup process when you sign up, give mailgun a subdomain like notifications.mydomain.com or whatever you want it to be, and then create these MX/SPF/DKIM records with your registrar for this new subdomain (it walks you through the setup the whole way, again shouldn’t take you more than 5 minutes.)

You can create as many mailgun ‘subdomains’ as you want, like I have one that is status.mydomain.com where I just send out notifications about outages. And in the WordPress plugin, you can customise the ‘sender’ of the outgoing emails, as long the email is coming from your own FQDN. For example I can make the sender(s) be orders@; receipts@ – I just can’t change the domain name itself after the @ (unless I own that domain and verify it as well.). The email addresses you use to send out email from mg don’t actually need to exist (but if someone replies to them the reply will come back to whatever email you’ve told mailgun to forward replies to.)

If you choose to use it with WordPress, their plugin has an option to send your emails out via SMTP or their HTTPS API; https://wordpress.org/plugins/mailgun/

If you’re not using WordPress and need an outgoing/transactional email solution, I highly recommend you check out their website to see how easy it is to use with any language, not just PHP. Again I’m not connected with them in any way, it’s just I’ve been using them for over 5 years now to deliver my email newsletters, notification emails, woocommerce emails etc, and free 10k emails/month is extremely generous, I’ve never had any bounce backs or spam issues, so I thought I would give them a little shout out here (although this turned out to be a massive essay lol)


#15

LE: Nope, it’s working only for one domain. I don’t get it :frowning:

I managed to make it work by creating the missing /etc/aliases.db:

sudo vi /etc/aliases.db
# populate it with
root: root@yourdomain.com

It seems to work. Now, I don’t know what would happen after an ee update. Maybe support can throw some knowledge in here :slight_smile:


#16

Same issue with me. I have Contact Form 7 setup to email me whenever there’s a form submission, however I get an error if I’m using the same domain email address as my website. Using Gmail or Outlook email address, the form goes through, but I never get an email.