• Hi,

    I’m trying to use mail-tags for the “From:” header and the “Reply-to:” header.

    I have a SELECT setup like so:

    [select* location first_as_label "Select a Showroom" "Single Entry 1|[email protected]" Multiple Entry 1|[email protected],[email protected]" "Multiple Entry 2|[email protected],[email protected]"]

    In the “Mail” config tab for this form, I use “[location]” for the “From:” and “Additional Headers” (where the reply-to is generated, eg: Reply-to: [location]) fields.

    In no case does the “From:” header ever get replaced – it’s always using WP’s main setting for site email.

    For the reply-to, the [location] mail-tag works if there’s only one address, but the entire header is not even added if two addresses are included. Syntax for multiple is proper according to RFC 5322 – just put a comma between the addresses.

    Is there any reason the “From:” can’t be manipulated? The Additional Headers part seems more like a bug…

    The “additional headers”

Viewing 10 replies - 1 through 10 (of 10 total)
  • Plugin Author Takayuki Miyoshi

    (@takayukister)

    Where can we see the website in question?

    Thread Starter sporkme

    (@sporkme)

    It’s a staging site behind a user/pass…

    Plugin Author Takayuki Miyoshi

    (@takayukister)

    Thread Starter sporkme

    (@sporkme)

    OK, alternately, is there a function I can hook into to hopefully override whatever behavior is happening here?

    I was looking around here: https://contactform7.com/docs/ but didn’t really see any developer docs.

    Hello @sporkme,

    The plugin author wrote several post for developers called recipes in the category Developer’s cookbook.

    This may help you.

    Best regards,
    Yordan.

    Thread Starter sporkme

    (@sporkme)

    Had a quick look, but didn’t find anything totally relevant yet.

    Currently trying on a stripped-down site and seeing more things work, but also seeing this break in new ways. Putting multiple email addresses in on this site is generating the generic error “There was an error trying to send your message. Please try again later.”.

    Even withe WP_DEBUG enabled, there’s nothing in my php error log, apache error log nor the browser console. I would love to find a way to have CF7 output some debugging info.

    Thread Starter sporkme

    (@sporkme)

    This is getting nutty – two sites on one this works, on another it does not. Same version of WP, same version of CF7.

    On the not-working site even after disabling all CF7-related plugins, same behavior – the “From:” and “Addtional Headers” with “Reply-To” set are silently ignored.

    This seems to be happening well before the MTA is even involved.

    Thread Starter sporkme

    (@sporkme)

    OK, last ask for some insight here and then I’m just going to go with a workaround.

    Anyone familiar with the code for where mail-tags are parsed? I’m thinking somewhere there’s a test where this fails and default values are subbed in.

    Still looking for any general debug tips as well – thinking about hacking something into WP’s included phpmailer to see what CF7 is passing to phpmailer just in case phpmailer is the culprit here.

    Thread Starter sporkme

    (@sporkme)

    Slowly working through this, maybe it will be helpful to someone else?

    I added some debugging in includes/mail.php just before “wp_mail()” is called so I could see what’s inside “$headers” and whether the mail-tags were working. Looks like they work, but something further down the line (in wp_mail(), which I assume eventually uses PHPMailer) must be “fixing” something:

    This is the log – two emails are sent, one being to the form recipient, the other being the autoresponder:

    start cf7 log
    From: [email protected]
    X-WPCF7-Content-Type: text/plain
    Reply-To: [email protected]
    
    start cf7 log
    From: [email protected],[email protected]
    X-WPCF7-Content-Type: text/plain
    Reply-To: <[email protected],[email protected]>

    So my “From:” and “Reply-To:” are intact up to line 135 or so of “includes/mail.php” in CF7.

    Thread Starter sporkme

    (@sporkme)

    I figured most of this out. Debating whether to raise a bug with WordPress itself or not.

    First, the “From:” tag not being obeyed was easy. I found someone had stashed a filter in functions.php that was always overriding the From address. Removed that, problem solved.

    Second, what I was banging my head against with the Reply-To: field was the issue of it working in one place and not another, even with matching versions of everything. What I missed is where it was working, my “Additional Headers” had “Reply-to: [location]” and where it was not, I had “Reply-to: <[location]>”. Both are proper syntax… until you have multiple addresses. For example “<[email protected]>” is legit, as is “[email protected], [email protected]”, or “<[email protected]>, <[email protected]>”.

    “<[email protected], [email protected]>” is NOT, and that’s what “<[location]>” would generate.

    I can’t see an easy way to have CF7 validate something like that.

    I moved on to wp_mail() (in wp-includes/pluggable.php) before figuring out the issue and just added debug statements all over the place until I found my “$headers” array had lost the Reply-to. Around line 409 the reply-to is added using phpMailer’s “addReplyTo” method. If the syntax is incorrect, the header is not added, but wp_mail() DOES NOT catch and report the error.

    Any opinions on whether this is worth raising as a bug? The user/developer should be notified of syntax errors rather than just silently failing, but I have no idea how open to commentary the devs are…

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Mail tags ignored for From: and Reply-to:’ is closed to new replies.