Want to send email through wordpress

I am new to wordpress, I just installed wordpress on my godaddy server. I want to create a form on wordpress page where user will enter the details, name and password. when the user clicks on submit button of form, I want wordpress to send me an email with the details entered by user in the form. Please help me with this.

Related posts

Leave a Reply

3 comments

  1. I think the best solution would be to use a plugin. There are many plugins that help you create contact forms that would also send you an email with the details.
    Contact Form 7 is simple to set up and use.
    I hope that helps.

  2. There are some plugins, not sure if you want that. But if you don’t you can do it on your own.

    If you want to do it by yourself:

    This is the file that gets called by the request (usually an AJAX request):

    <?php 
    
    $client_email = $_POST["user_email"];
    $client_email = (string) $client_email;
    include('Mail.php');
    
    $recipients = 'email@gmail.com';  
    $headers['From']    = 'from@gmail.com'; 
    $headers['To'] = 'email@gmail.com';
    $headers['Subject'] = "subject";
    $body = "This is the content" ;
    
    // Define SMTP Parameters
    $params['host'] = 'ssl://smtp.gmail.com';
    $params['port'] = '465';
    $params['auth'] = 'PLAIN';
    $params['username'] = 'from@gmail.com';
    $params['password'] = 'yourpassword';
    
    //$params['debug'] = 'true';
    
    // Create the mail object using the Mail::factory method
    $mail =& Mail::factory('smtp', $params);
    
    // Send the message
    $mail->send($recipients, $headers, $body);
    

    Notes: