arrow_upward

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[SOLVED] wp_mail() function - Wordpress
#1
Question 
Hello Friends, I have created a blog.I have installed contact form 7 ( plugin ) for creating a contact us page.I have managed the form settings according to the recommendation.Now whenever i create a message to contact it shows that " There was an error trying to send your message. "
I asked it to the plugin author.He told me to check the solution from his website.I found that the message is showing error due to the wp_mail() function.I am not much expert in programming so asking here if anybody can help me to solve this.
I have explained in this link.
https://wordpress.org/support/topic/unab...t-11596828

Thanks to Post4VPS and Hostlease for their great services.  
#2
I can't stress this enough but when requesting for help and support try to provide as much information as possible.

1. Is your Wordpress site hosted on shared hosting or your own server?
2. Which web server, PHP and MySQL or MySQL derivatives versions are used?
3. If shared hosting is used: are you allowed to send mails? Some providers disable this function due to spam.
4. If you use your own server: is a local MTA installed to send mails or do you use a 3rd party service such as Sendgrid or similar?
5. Are you running the latest Wordpress and using the latest version of the plugin? A link to the actual used plugin would be helpful, too.

If you run your own server have you checked logs in /var/log?

Have you tried debugging this issue before by yourself? What were the results? Have you discovered something?


Little side question: How come you always post this kind of threads in the wrong forums?
[Image: zHHqO5Q.png]
#3
Use a the contact us plugins that are in WordPress plugins page
#4
(06-02-2019, 03:50 PM)Hidden Refuge Wrote: I can't stress this enough but when requesting for help and support try to provide as much information as possible.

1. Is your Wordpress site hosted on shared hosting or your own server?
2. Which web server, PHP and MySQL or MySQL derivatives versions are used?
3. If shared hosting is used: are you allowed to send mails? Some providers disable this function due to spam.
4. If you use your own server: is a local MTA installed to send mails or do you use a 3rd party service such as Sendgrid or similar?
5. Are you running the latest Wordpress and using the latest version of the plugin? A link to the actual used plugin would be helpful, too.

If you run your own server have you checked logs in /var/log?

Have you tried debugging this issue before by yourself? What were the results? Have you discovered something?


Little side question: How come you always post this kind of threads in the wrong forums?

OFF: For me it was in correct section.As i were asking about the function wp_mail() and off-course that is about scripts.

ON
I have hosted site on my own server
I am using Apache2, PHP 7.2, MySQL Version  5.7.26
I don't use any MTA.
Yea i have latest version of wordpress.
Here is the link to the plugin https://wordpress.org/plugins/contact-form-7/

BTW i have installed a WPForm SMTP.Now it is working well.But i am still interested to know why was it not working before and how to fix this manually because the email system is working well with this plugin using gmail.but i still need to fix that because the subscribe plugin is not able to send mails.
I have not decided any plugin yet for subscription.suggest me a if you have information about them.

https://wordpress.org/plugins/email-subscribers/
https://wordpress.org/plugins/mailchimp-for-wp/

Thanks to Post4VPS and Hostlease for their great services.  
#5
@Rehan

Despite the title, the topic has little to do with it (in the direct). You are directly requesting for help with a Wordpress blog and a form plugin for it. While the (in the title) mentioned function only hints towards the problem it isn't what causes the problem. This is being validated by your additional information that you posted on my request. So all in all you are requesting help for a web application and its plugin which is unrelated to scripting and programming (it is at least indirectly related).


Now to the main issue of this. You host the blog on your own VPS without a local mail transfer agent (MTA) or mail server. What that means should be obvious: you cannot send or receive any mail from or to the VPS. If that wasn't clear, I hope it is now. It is like attempting to drive a car without wheels.

Wordpress itself (rather said its wp_mail() function) heavily relies on using a local MTA or mail server to send out any kind of mails by default. This can be changed of course, by using either a plugin that rewrites wp_mail() to use a 3rd party service (GMail, Sendgrid, etc...) or by using plugins that come with their own SMTP server setup where you then can use a 3rd party service to send mails. You have decided for the last option by changing to "WPForm SMTP".

Now to the new problem "subscribe plugin is not able to send mails.". That is still because of the main root cause. The subscribe plugin relies on the wp_mail() function that doesn't work properly on your server due to a missing MTA or mail server. The SMTP setup from WPForm SMTP will no apply/work for other plugins. To solve this you either need a plugin that fully rewrites wp_mail() to use a 3rd party service or again a subscription plugin where you can specify an external SMTP server. Beware though that depending on the plugin, even with a rewriten wp_mail() function, it might still not work properly because it ignores changes of the main default Wordpress function and might use its own function that only relies on basic information from wp_mail() function like mail server, port, address and such.

I would say though that it is worth a try to test a plugin that rewrites the wp_mail() function to use a custom SMTP server like this one: https://wordpress.org/plugins/easy-wp-smtp/

I used one that worked really well years ago when I hosted Wordpress blogs for some friends and associates. Unfortunately I can't find it now. Maybe it is no longer working due to major version upgrades with Wordpress or it has rebranded to a different name. I don't know.


Unfortunately I cannot help with deciding for which of the both posted plugins to go. I have no knowledge about what the subscription plugin is for to give any ideas or advices. Hopefully the others have ideas or plugins about that Smile .
[Image: zHHqO5Q.png]
#6
@Hidden Refuge A big big thanks for your services.You are the first ever expert person in every field of IT.I used HF ( h*******s ) for a long time for learning but never seen a expert like you. A big Thanks dude.

Also i want to ask another question that what if i setup a mail server?

https://www.hostinger.com/tutorials/how-...on-ubuntu/

Also i want to provide you information that i am using Cloudflare for DNS.

Thanks to Post4VPS and Hostlease for their great services.  
#7
If you using a custom DNS service such as Cloudflare the part of the guide is not really applicable to you. You can continue from "How to Install and Setup Mail Server on Ubuntu 18.04" I would say in that case. That said you will have to setup some DNS records at Cloudflare later on like MX records, SPF and such. The following might be a shock for you and others but I never bothered to setup a mail server on my own server at my own because it is too much hassle these days with all the necessary work to get the mails to work and not be blocked or land in spam. So I'm not really the correct person to ask in that case. Sorry about that Smile .

If you plan to use your own mail server on the VPS you still need a plugin that will allow you to configure the wp_mail() function to use the server. I found this guide: https://coderwall.com/p/hogffa/sending-e...-localhost

It's basically the same plugin that I linked before Smile . Instead of hosting your own server you can also use the free Sendgrid plan which allows 40.000 mails for the first 30 days and then 100 mails per day. If you don't exceed 100 mails / day this should work better initially than the hassle to setup a properly working mail server.

So you can use the plugin together with Sendgrid to send out mails. I used to do this on the Wordpress blogs I hosted and we still do it at FreeVPS.us (well, the Sendgrid account is enabled and configured for it, but because it is closed no e-mails are being sent obviously unless someone does something like "Forget password" or similar).

Other 3rd party SMTP services with free plans are:
- MailGun (10.000 mails / month)
- SendInBlue (9.000 mails / month)
[Image: zHHqO5Q.png]
#8
putting all your site data, scripts, db, mail system on the same vps is bad idea. I suggest that you use external smtp services as mentioned by HR above.
I remember liking mailchimp for subscription. More options for control and analysis.
Sincere Thanks to VirMach for my VPS9. Also many thanks to Shadow Hosting and cubedata for the experiences I had with their VPSs.
#9
The topic can be marked as solved.The problem was solved.

Special Thanks to @Hidden_Refuge





@deanhills

Thanks to Post4VPS and Hostlease for their great services.  
#10
Discussion marked as solved and closed as per request of author of topic.
Terminal
Thank you to Post4VPS and VirMach for my awesome VPS 9!  
lockThread Closed 


person_pin_circle Users browsing this thread: 1 Guest(s)
Sponsors: VirMach - Host4Fun - CubeData - Evolution-Host - HostDare - Hyper Expert - Shadow Hosting - Bladenode - Hostlease - RackNerd - ReadyDedis - Limitless Hosting