• Wondering why wp_mail is not working. I am using it in a simple manner sending a text email without setting any headers. I get no errors but it seems as if the e-mail never gets sent as I haven’t received it anywhere.
    According to tests it is also returning back as false…. What stupid thing am I doing wrong as usually when I’m having an issue the solution is right in front of my face.

    Could anyone provide me with some clarity on this issue?

    //** Task Related Functions
    function rfd_close_task($post_id){
    	$post = get_post($post_id); //Use for later
    	$post_url = site_url('wp-admin/post.php?post=' . $post_id . '&action=edit');
    	$old_task = get_post_meta( $post_id, 'task-type', true );
    	$johnum = get_post_meta( $post_id, 'jobnum', true );
    	//Get Creator info to get $to info
    	$creator = get_post_meta( $post_id, 'creator', true );
    	$creator_obj = get_users(array('search' => $creator));
    	$to = $creator_obj[0]->user_email;
    	//Get Current Date/Time
    	$c_date = date( 'm/d/Y', time());
    	$c_time =  date( 'g:ia', time());
    
    	$subject = $old_task . ' completed for ' . $jobnum;
    
    	if($old_task == 'HFC Estimate'){
    	  // Get date/time of current estimate task
    	  $est_tstamps = explode(",", get_post_meta( $post_id, 'hfc-estimate', true ));
    	  $count = count($est_tstamps)  - 1;
    	  $est_tstamp = $est_tstamps[$count];
    	  $est_date = date( 'm/d/Y', $est_tstamp);
    	  $est_time =  date( 'g:ia', $est_tstamp);
    	  // Create message
    	  $message = 'The ' . $old_task . ' created on ' . $est_date . ' at ' .  $est_time . ' has been completed on ' . $c_date . ' at ' . $c_time . '.  Please visit "' . $post_url .'" to assign the next task for this job.';
    	  // Reset update counter
    	  update_post_meta( $post_id, 'hfc-est-update-count', 0);
    	} 
    
    	if($old_task == 'Field Survey' || $old_task == 'Fiber Survey' || $old_task == 'HFC Survey'){ // @toDo -- E-mail creator of task for review of closed job.
    		update_post_meta( $post_id, 'job-closed', 'Job Closed' );
    	}
    	update_post_meta( $post_id, 'task-type', 'Select Task', $old_task );
    	wp_mail( $to, $subject, $message );
    
    }
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘wp_mail not working’ is closed to new replies.