If you like DNray Forum, you can support it by - BTC: bc1qppjcl3c2cyjazy6lepmrv3fh6ke9mxs7zpfky0 , TRC20 and more...

 

WP Mail Function

Started by Stranger, Jul 20, 2022, 03:00 PM

Previous topic - Next topic

StrangerTopic starter

I am unable to use the wp_mail() function on my hosting provider, either because it is not configured correctly or because it is prohibited. Moreover, phpmail is also not functional since port 25 is closed. Has anyone else encountered this issue?
At the start, I only need to send a maximum of ten emails per day, but this volume will increase over time. I have considered using a traditional email service to send my emails, but I am uncertain about the best way to proceed.
  •  


Ali_Pro

Sending emails through PHP is not the most efficient method as it goes through multiple filters and servers, which increases the likelihood of lost or undelivered emails, especially with smaller providers. Nowadays, it is recommended to use major email services such as Google and Outlook, which offer encrypted channels for direct delivery from your PHP script to their mail sending servers.

If you are using Wordpress, the solution is simple: install the WPMail SMTP plugin and select your preferred email service. If you have any questions, feel free to contact me.
Ali.
  •  

StrangerTopic starter

I installed the plugin, and tried to enter my password and login from my Google account. The account was registered many years ago.
But for some reason the plugin is not working. Not even a connection.
I tried many times. I'm probably doing something wrong.
  •  

Ali_Pro

Yes, you made a mistake. ;)  The most classic. And she is terrible!  ;D
You didn't read the instructions.
We are not working with your mailbox access settings, in this case we are using Google Workspace account via the Google API.
It is important!
Please carefully read the section on working with the Google Workspace account, the authors of the plugin very punctually described the entire mechanism of action. I think if you do everything according to the points, and this is not a big deal, then everything will work out.
Here is the link in the plugin:

You cannot view this attachment.

After completing the setup, do not forget to send a test email to any address. The function is located on the 2nd tab of the plugin settings.
Ali.
  •  

Ali_Pro

This is how the received test email will look like. If the test passes, it means that you are already using on your site all the benefits of working through Google's powerful SMTP. Additionally, I recommend looking at section on SPF and DKIM.You cannot view this attachment.
Ali.
  •  

StrangerTopic starter

I finally figured out how to create a WEB application in the Cloud Console. Enabled Gmail API for my project. Got the client ID and secret and switched the application from to external mode. I inserted the ID and secret into WP Mail SMTP, everything worked right away.
Learned a lot.
Thank you, it really helped me!
  •  

Ali_Pro

Please.  :)
By the way, the plugin has the ability to work not only with the API of the service, but also as a simple mail client with the usual SMTP authorization via STARTTLS on port 25 or TLS on port 465.
Ali.
  •  


_AnnA_

Quote from: Ali_Pro on Jul 22, 2022, 10:01 AMBy the way, the plugin has the ability to work not only with the API of the service, but also as a simple mail client with the usual SMTP authorization via STARTTLS on port 25 or TLS on port 465.

I use this plugin for domain mail on byethost.com. Everything suits me in the hoster, but they have SMTP sending disabled. The plugin allows you to bypass this limitation. I don't use the API, the plugin just connects to gmail as a trusted one.
The option you are writing about.
  •  

infibeam

The wp_mail() function is a pluggable feature in WordPress that facilitates email delivery throughout the platform. Its setup is quite versatile, as it enables you to use the default HTML template for all email dispatches from your WordPress installation.

In addition, it allows you to create a backup by sending a BCC copy of each message to a specific email address, which can be useful when recipients are unable to receive emails. By default, the email type for wp_mail() is text/plain, which means HTML tags cannot be used in the body of the email. However, you can modify this setting by using the wp_mail_content_type filter or specifying the header: content-type: text/html.
Moreover, the encoding for wp_mail() defaults to the same encoding as your blog (usually utf-8), but can be adjusted through the wp_mail_charset filter.
  •  

Edgar

Considering your initial requirement of sending a maximum of ten emails per day, you have the opportunity to leverage third-party email services, such as SendGrid, Mailgun, or Amazon SES, to handle your email needs. These services offer robust APIs that can be easily integrated into your website or application. They also provide comprehensive deliverability optimization, analytics, and scalable infrastructure, ensuring that your emails are successfully delivered and that you can manage increasing email volumes over time.

In the case of SendGrid, for example, their free tier allows you to send up to 100 emails per day, which can cater to your current needs without incurring any costs. As your email volume expands, you can effortlessly upgrade to a paid plan that will accommodate your growing requirements.

By opting for a third-party email service, you can ensure that your emails are not affected by the limitations of your hosting provider and that you have access to advanced features such as email tracking, detailed analytics, and improved deliverability. Most of these services also provide client libraries and plugins for various programming languages and web development frameworks, easing the integration process and allowing you to make the most of their capabilities without significant development effort.
  •  


If you like DNray forum, you can support it by - BTC: bc1qppjcl3c2cyjazy6lepmrv3fh6ke9mxs7zpfky0 , TRC20 and more...