WordPress custom from mail not working

Question

Custom from mail not working. I’ve tried it in the ways mentioned on the WordPress website and on Stackoverflow.

apply_filters(‘send_password_change_email’, function( $send, $user, $userdata ){

if( !$send ) {
  return $send;
}
// Your custom email logic
// ...

// tell wordpress not to send the built-in email
return false;

}, 10, 3);
function wpse_new_mail_from( $old ) {

return 'atendimento@agetec.campogrande.ms.gov.br'; // Edit it with your email address

}

function wpse_new_mail_from_name( $old ) {
return ‘AGETEC’; // Edit it with your/company name
}
function change_password_change_admin_email( array $pass_change_email ) {
$admin_email = get_option(‘admin_email’);
$pass_change_email[‘message’] = str_replace( $admin_email, ‘atendimento@email.com’, $pass_change_email[‘message’] );

return $pass_change_email;

}
add_filter( ‘password_change_email’, ‘change_password_change_admin_email’ );

add_filter( ‘wp_mail_from’, ‘custom_slug_mail_from’ );

/**

  • Function to change mail_from to input entered via form.
    */
    function custom_slug_mail_from( $email ) {

    /**

    • Use the user-submitted email if present.
      */
      if ( isset( $_REQUEST[ ’email_from_form’ ] ) ) {
      var_dump($_REQUEST[ ’email_from_form’ ]);die;
      return sanitize_email( $_REQUEST[ ’email_from_form’ ] );
      }
      var_dump($email);die;
      return $email; // if no email submitted, use default.
      }
      remove_filter(‘wp_mail_from’,’custom_wp_mail_from’);
      remove_filter(‘wp_mail_from_name’,’custom_wp_mail_from_name’);
      add_filter( ‘wp_mail_from’, ‘wpse_new_mail_from’ );
      add_filter(‘wp_mail_from_name’, ‘wpse_new_mail_from_name’);ord
0
wander arce 4 months 0 Answers 13 views 0

Leave an answer