简体   繁体   中英

Joomla 3.x Contact Form - Automatic Email Edits

Please be aware I am not very familiar with JavaScript and I am doing this to help out a coworker.

I am trying to make an edit to the contact form automatic email replies. The change I am looking to make is when a person sends an email to someone on the website a reply is sent back to the person stating "This is a copy of the following message you sent to WEBSITE PERSON via WEBSITE NAME." The person receiving the email only gets the name of the person that sent it and the message.

I need to add the "This is a copy of the following message you sent to WEBSITE PERSON via WEBSITE NAME" message to the other email because one person is receiving all emails and sending them to the appropriate person. I know, this sounds unreasonable but it is what has been requested.

I found the code in contact.php but I am not entirely sure how to make the change.

This is where the code is getting the portion that I need:

    // Check whether email copy function activated
        if ($copy_email_activated == true && !empty($data['contact_email_copy']))
        {
            $copytext    = JText::sprintf('COM_CONTACT_COPYTEXT_OF', $contact->name, $sitename);
            $copytext    .= "\r\n\r\n" . $body;
            $copysubject = JText::sprintf('COM_CONTACT_COPYSUBJECT_OF', $subject);

            $mail = JFactory::getMailer();
            $mail->addRecipient($email);
            $mail->addReplyTo($email, $name);
            $mail->setSender(array($mailfrom, $fromname));
            $mail->setSubject($copysubject);
            $mail->setBody($copytext);
            $sent = $mail->Send();
        }

        return $sent;
    }
}

And I need the above to work with

// Prepare email body
    $prefix = JText::sprintf('COM_CONTACT_ENQUIRY_TEXT', JUri::base());
    $body   = $prefix . "\n" . $name . ' <' . $email . '>' . "\r\n\r\n" . stripslashes($body);

    // Load the custom fields
    if (!empty($data['com_fields']) && $fields = FieldsHelper::getFields('com_contact.mail', $contact->email_to, true, $data['com_fields']))
    {
        $output = FieldsHelper::render(
            'com_contact.mail',
            'fields.render',
            array(
                'context' => 'com_contact.mail',
                'item'    => $contact,
                'fields'  => $fields,
            )
        );

        if ($output)
        {
            $body .= "\r\n\r\n" . $output;
        }
    }

    $mail = JFactory::getMailer();
    $mail->addRecipient($contact->email_to);
    $mail->addReplyTo($email, $name);
    $mail->setSender(array($mailfrom, $fromname));
    $mail->setSubject($sitename . ': ' . $subject);
    $mail->setBody($body);
    $sent = $mail->Send();

I thought it would be as simple as copying some code around but I am was very wrong. I knwo there are overrides in Joomla to prevent core code from being touched. As soon as I can get this figured out I can do the override to properly add my changes.

Thank you in advance!

Sorry, i used mobile so it hard to check

// Check whether email copy function activated if ($copy_email_activated == true && !empty($data['contact_email_copy'])) { $copytext = JText::sprintf('COM_CONTACT_COPYTEXT_OF', $contact->name, $sitename); $copytext .= "\r\n\r\n" . $body; $copysubject = JText::sprintf('COM_CONTACT_COPYSUBJECT_OF', $subject); 

// Load the custom fields if (!empty($data['com_fields']) && $fields = FieldsHelper::getFields('com_contact.mail', $contact->email_to, true, $data['com_fields'])) { $output = FieldsHelper::render( 'com_contact.mail', 'fields.render', array( 'context' => 'com_contact.mail', 'item' => $contact, 'fields' => $fields, ) ); if ($output) { $copytext .= "\\r\\n\\r\\n" . $output; } }

$mail = JFactory::getMailer(); $mail->addRecipient($email); $mail->addReplyTo($email, $name); $mail->setSender(array($mailfrom, $fromname)); $mail->setSubject($copysubject); $mail->setBody($copytext); $sent = $mail->Send(); } return $sent; } }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM