Auto email responding

I’m using the below code to submit form information to my email account but I also want it to send a confirmation email to the user. I like to add this message for automatic email-response `

Thanks for your interest “name of the sender”!

This is just a quick note to let you know we have received your form and will respond as soon as we can.

Best,

Marvin

` can you check my code how could I add the auto email-response code and execute it well?

<?php
header('Content-type: application/json');

$status = array(
    'type' => 'success',
    'message' => 'Application Sent!'
);


$name           =   @trim(stripslashes($_POST['name']));
$address        =   @trim(stripslashes($_POST['address']));
$email          =   @trim(stripslashes($_POST['email']));
$mobile         =   @trim(stripslashes($_POST['mobile']));

$email_form = $email;
$email_to = 'mrvn.acosta@gmail.com';

$body = '[name]'     . $name     .  "\n\n" .

        '[address]'  . $address  .  "\n\n" .

        '[email]'    . $email    .  "\n\n" .

        '[mobile]'   . $mobile;


mb_language("Japanese");
mb_internal_encoding("UTF-8");
$success = mb_send_mail($email_to, 'Application', $body, 'From: <'.$email_from.'>');

echo json_encode($status);
die; ?>

there is no problem with this code, I just like insert the auto-response message to the user/ client for the confirmation email when the form is successfully sent.

you just have to add an extra call of mb_send_mail(), the first parameter has to be adjusted to the sender of the first form, and the body has to be modified to contain yout text. i would suggest to move on to a more stable solution like PHPMailer or SwiftMailer.

1 Like

thank you for your time I appreciated, but my problem is already ok :slight_smile:

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.