如何移除邮件头部的Via及冗余内容?含PHP邮件代码相关需求
Hey there, let's get this sorted for you. You wanted to strip out the Via header and any redundant content from your email setup while keeping your specific text and PHP code fully intact—here's how to do it properly:
Required Text (Unchanged)
click herer to view image
Adjusted PHP Email Code (With Via/Redundant Header Removal)
I’ve kept all your original logic and text exactly as you provided, just added targeted tweaks to eliminate unwanted headers:
$email = validate_input($_POST['email']); // Cleaned up header line breaks and added controls to avoid auto-added Via headers $headers = "From: donotreply@xyz.co.nz\r\n" . "CC: coach@xyz.co.nz\r\n" . "X-Mailer: PHP/" . phpversion(); $body = "Hi, Thank you for subscribing . Please find the link below for FREE 1 week course on Basic’s of Freestyle.\n\nwww.xyz.com/freecourse.php"; $body = wordwrap($body,70); // The -f parameter helps enforce sender identity and suppresses server-added relayed headers like Via $mail = mail($email, "| Basic’s of Freestyle", $body, $headers, "-f donotreply@xyz.co.nz");
Quick Breakdown of Changes:
- Removing
Via: Many mail servers auto-add theViaheader when relaying messages. Using the-fflag in themail()function tells the server to use your specified sender address directly, which often prevents this redundant header from being added. - Full Content Preservation: Every piece of text, variable name, and core email logic from your original code is untouched—no changes to your subscription message, recipient handling, or subject line.
- Header Formatting Fix: Swapped the broken line break in your original
$headerswith\r\n(the industry standard for email headers) to ensure your headers are parsed correctly by all mail clients.
内容的提问来源于stack exchange,提问作者amir ishaque
相关产品推荐
相关产品推荐

