-1

I have a plugin in WP which I am going to modify. At some point I have to send an email and I have the option to choose between wp_mail and mail. I decided for the first one, at least it seems plugged in the WordPress environment. Even if I read the documentation, I can't understand how it could protect me more than mail. But a reason has to be there.

In general, may i consider the script safe if I am sending email by using wp_mail within a plugin with the parameters to, subject, body, header, "-f info@mdomain.com" ? Are there best practices to make this function safer? My concern is that for whatever reason the WP installation could be hacked and this script used to send unsolicited emails.

Regards Fabio

Fabio Ricci
  • 395
  • 1
  • 4
  • 16
  • who told you that wp_mail is more secure than mail ? mail is an internal php function, wp_mail is often use mail function with more options – hassan Apr 01 '17 at 07:29

1 Answers1

1

who told you that wp_mail is more secure than mail ?

mail is an internal php function

while wp_mail is often use mail function with more options to make it easier to send an emails using wordpress instead of re-implement new implementation to a mail object.

wp_mail uses PHPMailer class, which is using by default mail function.

/**
 * Which method to use to send mail.
 * Options: "mail", "sendmail", or "smtp".
 * @var string
 */
public $Mailer = 'mail';

however, if you took a quick look in the implementation of wordpress wp_mail function , you will notice a poor implementation , they still using global variables which is considered as a poor practice .

Community
  • 1
  • 1
hassan
  • 7,812
  • 2
  • 25
  • 36
  • I didn't said that. I said, it seems... documentation is a bit unclear, sorry for being vague. However, if you would have to send an email from within a WP plugin made by others, which function would you use when it comes to security? Consider that the plugin itself is using wp_mail. – Fabio Ricci Apr 01 '17 at 07:56
  • wp_mail will be okey , or you may write your own small mail handler , sorry but I does not use wordpress too much – hassan Apr 01 '17 at 08:03