wordpress contact form messages not sending although it saying they were sent successfully with this php code

The mail() function (used by wp_mail() function, assuming there is no other mail plugin added to your site) sends the mail stuff to your domain’s mail server. It only knows if the message was recieved by the mail server. It does not know if the message was actually sent out by your mail server.

One of the things that can cause problems is that the ‘from’ email sent via the mail() function must be a email address in your domain. It does not have to exist, just has to be from your domain.

For example, if your domain is www.example.com , then the ‘from’ email needs to be ‘[email protected]’. It cannot be ‘[email protected]’. That will be blocked by your mail server.

So it is important the the sender of your message be in your domain. If not, your email server – or a recipient’s mail server – will sense the message as being probably spam, and will refuse/block/not send your message.

You can set the ‘reply-to’ header value to anything, even an email not in your domain, but the sender MUST be an email address that matches your domain.

Note that the wp_mail() function sends mail from the ‘default WordPress email’ account. You must make sure that this is set up properly. This setting is in Settings, General, Administration Account. That value must be set to [email protected] , replacing your domain name.