0

I am creating a function in a template that will send an email using wp_mail function.

My question is if it can be used be not logged in users or not.

I mean directly from a template file like (it's just an example, in my real example it's much more code):

<?php
/**
 * Template Name: Custom Template
 *
 *
 * @package WordPress
 * @subpackage Twenty_Twelve
 * @since Twenty Twelve 1.0
 */

get_header(); ?>

<?php


    $headers = 'From: Tester 1 <[email protected]>' . "\r\n";
    $subject = 'Subject test' . "\r\n";
    $message = 'Just a test stuff.';
    wp_mail('[email protected]', $subject, $message, $headers );


?>

<?php get_sidebar(); ?>
<?php get_footer(); ?>

If not, how can I simulate logged in user just for this thing?

It's not working for me right now, so I was thinking that I need soem more permission maybe?

2
  • Are you testing locally?
    – gmazzap
    Commented Sep 6, 2013 at 21:52
  • @G.M. No, on the server.
    – Derfder
    Commented Sep 7, 2013 at 4:57

1 Answer 1

1

My question is if it can be used be not logged in users or not.

Yes. wp_mail() works fine from the front end when not logged in. I use it for a contact page on my web site.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.