1. AMIMOTO Help Center
  2. Amimoto AMI
  3. Trouble shooting for Amimoto AMI

WordPress cannot send user registration email or password reset email.

It's WordPress core related issue, simply install and activate AMIMOTO Plugin Dashboard to solve it.

Issue

WordPress could not send password reset emails or user registration e-mails with the following error message.

The email could not be sent.
Possible reason: your host may have disabled the mail() function. 

Conditions

  • Running AMIMOTO AMI from AWS MarketPlace.
  • You haven't added domains or virtual hosts with wp-setup command.

    Note: This issue will not appear in Managed Hosting.

 

Solutions

A. Get hostname from DB of WordPress and use it as host section of the email address. 

e.g. create functions.php with the following code:

function my_wp_mail_from( $original_email_address ) {
    return 'wordpress@' . parse_url( get_home_url( get_current_blog_id() ), PHP_URL_HOST );
}
add_filter( 'wp_mail_from', 'my_wp_mail_from' );


The AMIMOTO Plugin Dashboard has above code, simply install and activate it to solve the issue.
   

B. Edit server_name directives

Modify /etc/nginx/conf.d/default.conf and restart nginx.

Before modification:

server {
    listen      80;
    server_name _ default;
    root        /var/www/vhosts/i-a39asg02ar234srgas7293hga9w745;
    index       index.html index.htm;
    charset     utf-8;

After modification:

server {
    listen      80;
    server_name www.example.com default;
    root        /var/www/vhosts/i-a39asg02ar234srgas7293hga9w745
    index       index.html index.htm;
    charset     utf-8;

Note: you'll need to replace with www.example.com to your domain or URL.
 

C. Add a new virtual host then use it.

Adding a new WordPress (virtual host), you may need to data migration from current.

$ sudo su -

# cd /var/www/vhosts/
# wp-setup www.example.com

Cause

It is WordPress' core related issue. You can check it on the trac of WordPress 4.9 

Nginx send WordPress $server_name  which is ruled by in /etc/nginx/fastcgi_params as
fastcgi_param  SERVER_NAME        $server_name;

As in the official document describes,
> $server_name
>    name of the server which accepted a request
$server_name  is the requested server name from the browser which is consist of the configuration file.
If $server_name  is undefined, WordPress could not resolve the hostname and sent emails correctly.