Test message is sent but real message don't (2 posts)

  1. steven_barragan0
    Posted 4 years ago #

    Hi, I already configured my smtp to send emails, I tried to send the test email and it said that everything was ok, but when I want to send a email like this

    $to = 'steven@toolsnet.mx';
    $subject = $_POST['subject'];
    $messaje = "Telefono: $_POST[phone]\r\n$_POST[mail]";
    $headers = "From: $_POST[name] <$_POST[email]>" . "\r\n";
    echo json_encode(array('success' => true, 'result' => wp_mail($to, $subject, $message, $headers)));

    it doen's work, the function only retur me "False", may somebody help me??


  2. steven_barragan0
    Posted 4 years ago #

    In order to send the message, I had to check what the plugin was doing and I had to copy what all what it does to send the test messaje and my code now looks like this.

    ` global $wpms_options, $phpmailer;
    if (!is_object($phpmailer) || !is_a($phpmailer, 'PHPMailer')) {
    require_once ABSPATH . WPINC . '/class-phpmailer.php';
    require_once ABSPATH . WPINC . '/class-smtp.php';
    $phpmailer = new PHPMailer();

    $to = 'steven@toolsnet.mx';
    $subject = $_POST['subject'];
    $message = "Telefono: $_POST[phone]\r\n$_POST[mail]";
    $headers = "From: $_POST[name] <$_POST[email]>" . "\r\n";

    $data['messaje'] = wp_mail($to, $subject, $message, $headers);
    $data['success'] = true;`

    I hope it would be usefull to someone whit the same problem than me.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • WP Mail SMTP
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic