Support » Plugin: Mail Integration for Office 365/Outlook by Cross Connected » Contact form emails not working

  • Resolved nicolarossi31

    (@nicolarossi31)


    It works beautifully sending email related to Woocommerce. But it doesn’t send to the standard WordPress contact form emails to me. Anyone knows if this is fixable?

    The page I need help with: [log in to see the link]

Viewing 15 replies - 1 through 15 (of 24 total)
  • Plugin Author edwardcross

    (@edwardcross)

    Thanks for the message, and sorry to hear you’re having issues. I’m a little confused when you mention “WordPress standard contact form emails”, as WordPress doesn’t come with any contract form functionality. Such functionality is always provided by third-party plugins. Can you elaborate a bit more? What plugin actually provides your contact form functionality on your site?

    Thread Starter nicolarossi31

    (@nicolarossi31)

    Hi Edward. Thank you for your reply. Sorry, it is the Divid contact form standard module, not the WordPress.
    Nicola

    Thread Starter nicolarossi31

    (@nicolarossi31)

    Divi*

    Plugin Author edwardcross

    (@edwardcross)

    Thanks, I’ll try downloading this and testing with my plugin when I get a spare moment.

    Thread Starter nicolarossi31

    (@nicolarossi31)

    There is also a strange thing happening:
    I keep on receiving empty mails with as object: “New message from [website name] – Desideri ricevere supporto? Compila il form!” Translated: “New message from [website name] – Would you like to receive support? Fill out the form!”.

    These emails are sent from myself, to myself, automatically.

    Hi,

    These emails are sent from myself, to myself, automatically.

    This is expected, as this plugin mails from your account. so if you configure info@yourwebsite.com and you configure the recipient as info@yourwebsite.com then this will happen. It is probably a plugin that is sending the email.

    On topic:

    The problem seems to be Divi, as it incorrectly constructs the To header.
    I have installed a fresh copy of the newest WordPress and Divi.
    Divi calls wp_mail() in Divi/includes/builder/module/ContactForm.php on line 641.
    on line 628 it constructs the FROM header.

    $headers[] = "From: \"{$contact_name}\" <mail@{$http_host}>";

    If i use

    wp_die(print_r(headers));

    on the next line the output is:

    Array ([0] => From: “test”)

    the emailaddress is not there.

    A simple workaround is to modify the main file of this plugin: /wp-content/plugins/mail-integration-365/mail_integration_365.php

    Add these two lines:

    // Workaround for Divi contact form
    $headers = "";

    as show below here:

    55	    function wp_mail($to, $subject, $message, $headers = "", $attachments = array())
    56	    {
    
    				// Workaround for Divi contact form
    				$headers = "";
    				
    57	        // This filter is used to catch wp_mail arguments
    58	        $args = apply_filters("wp_mail", compact("to", "subject", "message", "headers", "attachments"));
    59	
    60	        if($args['error_message']) {
    61	            error_log($args['error_message']);
    62	           
    63	            return false;
    64	        } else {
    65	            return true;
    66	        }
    67	    }

    @edward Cross, maybe it is possible to set the FROM header to the default or the send as emailaddres when it is empty?

    • This reply was modified 4 months, 1 week ago by pyiter.

    Correction,

    In the answer above I said that the emailaddress is missing. That is because its picked up as html on the wp_die() page:

    <mail>

    So its probably filled in. Maybe an option to enforce a from name and emailaddress should fix this?

    Thread Starter nicolarossi31

    (@nicolarossi31)

    Hi Pyiter, thank you for your detailed reply. However i think it is too technical for me to understand what to do. Was it for @edwardcross ? Or is there something for me to do ?
    Btw, do you know about any contact form that works with this plugin?
    Thank you!

    Plugin Author edwardcross

    (@edwardcross)

    Hi both,

    I don’t beleive the To or From header being set by Divi is the issue here. However, the Divi plugin is not free, and the code seems hard to come by.

    Having searched on Github, I did find reference to what appeared to be a branched version of the ContactForm.php file and it didn’t seem to be setting the To header incorrectly. The from header is irrelevant to my plugin, as I deliberately don’t use it for the API as it would in many cases defeat the point of using the plugin to avoid mail ending up in the spam box (especially if the from address is from a different domain to the Office 365 mail account used to send the emails via my plugin).

    The only exception to this is the use of the “send as” option within my plugin settings, which allows you to change the From address, but only for a domain registered with the Office 365 account. Instead, I think the issue is more to do with how the wp_mail pluggable function is working.

    I have finally got my head around how to ensure headers are appropriately forwarded, whilst accommodating filters, and I think therefore, the new version of my plugin that I will be releasing shortly should help address the issue experienced here (although without access to the paid for Divi plugin, I can’t test it).`

    • This reply was modified 4 months, 1 week ago by edwardcross.
    • This reply was modified 4 months, 1 week ago by edwardcross.

    Hi,

    @nicolarossi31 I don’t know which contactform does work or not work, as I have installed this plugin for the first time last weekend.

    You could try if WPforms does work.

    @edwardcross If you could send me the changes/new version I am willing to test it. Or a download link.

    Resetting the $headers variable does work for me for some reason. I am using the send as option on the website where I configured this plugin.

    Plugin Author edwardcross

    (@edwardcross)

    @edwardcross The emails dont arrive when I updated to the new beta, when I added

    $headers ="";

    as above, it does work again.

    @pyiter Could my issue be related to a same cause (see post in the past)? I am really trying to figure out why the “reply-to” in the orders and contact forms are not usable in outlook.

    Plugin Author edwardcross

    (@edwardcross)

    @dyin @pyiter @nicolarossi31 if you have a test site, please can you test this version of the plugin? https://bit.ly/37p8dXQ

    Thanks,

    Ed

    @edwardcross I will test it later today or tomorrow. Thanks for the work trying to figure out the issue. I really apreciate it.
    We have again verified the source of the e-mails and compared it to the ones send before I installed this plugin. For some reason the “reply-to” is no longer present in the header. No other website changes were made.

Viewing 15 replies - 1 through 15 (of 24 total)
  • You must be logged in to reply to this topic.