Forums

wp_mail() not working (6 posts)

  1. windskystar
    Member
    Posted 1 year ago #

    I am trying to add a new user, but it is not sending an email to people whose emails are hotmail.com or gmail.com. I noticed that it is calling wp_email().

    I installed SMTP and had a correct smtp host, username and pswd, but it's not working.

    Is there any configuration that I need to make or a plugin that I need to install?

    Thanks. Please help.

  2. James
    Happiness Engineer
    Posted 1 year ago #

  3. windskystar
    Member
    Posted 1 year ago #

    I tried, but it doesn't work. but mail() works. is there any difference?

  4. James
    Happiness Engineer
    Posted 1 year ago #

    Then everything should be working properly. Contact your hosting provider. It's possible that your server has been blacklisted by Gmail and Hotmail's spam filters, which is unfortunately a common occurrence with most shared hosting providers.

  5. windskystar
    Member
    Posted 1 year ago #

    But it works when I used mail(). So I doubt that it's a spam filter.

  6. gillespieza
    Member
    Posted 1 year ago #

    Have you checked that wp_mail() is working if you provide all the arguments is needs?

    Try creating a simple template file in your theme folder, like so:

    <?php
    /* Template Name: Test */
    get_header();
    // $headers = 'From: My Name <myname@mydomain.com>' . "\r\n\\";
    wp_mail('myname@mydomain.com', 'The subject', 'The message',  $headers); 
    
    get_footer(); ?>

    Then create a test page using "Test" as the template. Preview the page (you shouldn't see anything on the page, actually) and then check your email. If you still get nothing, uncomment the line with $headers (just delete the two // at the start of the line). Save the template, reload the test page, and check your mail again. If it now works, the problem is that there is no "from" address being set when wp_mail is being called elsewhere.

    On my host, simply creating an email user "wordpress@mydomain.com" fixed the problem.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags