<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Plugin | Digital Nomad Blog</title>
	<atom:link href="https://online-dentist.hu/en/tag/plugin/feed/" rel="self" type="application/rss+xml" />
	<link>https://online-dentist.hu</link>
	<description></description>
	<lastBuildDate>Sat, 17 Jan 2026 10:13:46 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.0</generator>

<image>
	<url>https://online-dentist.hu/wp-content/uploads/2025/11/cropped-logo_circle_transparent-32x32.png</url>
	<title>Plugin | Digital Nomad Blog</title>
	<link>https://online-dentist.hu</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>[9] How I Built a Dual-Language Email Page Sender Plugin for WordPress</title>
		<link>https://online-dentist.hu/en/how-i-built-a-dual-language-email-page-sender-plugin-for-wordpress/</link>
					<comments>https://online-dentist.hu/en/how-i-built-a-dual-language-email-page-sender-plugin-for-wordpress/#respond</comments>
		
		<dc:creator><![CDATA[Steve – Digital Nomad]]></dc:creator>
		<pubDate>Fri, 07 Nov 2025 09:37:52 +0000</pubDate>
				<category><![CDATA[How I Built IT]]></category>
		<category><![CDATA[Plugin]]></category>
		<category><![CDATA[Wordpress]]></category>
		<guid isPermaLink="false">https://online-dentist.hu/?p=4226</guid>

					<description><![CDATA[<p>A lightweight WordPress plugin that lets visitors email the current page’s content to themselves, with built-in SMTP support and automatic bilingual detection.</p>
<p>The post <a href="https://online-dentist.hu/en/how-i-built-a-dual-language-email-page-sender-plugin-for-wordpress/">[9] How I Built a Dual-Language Email Page Sender Plugin for WordPress</a> first appeared on <a href="https://online-dentist.hu">Digital Nomad Blog</a>.</p>]]></description>
										<content:encoded><![CDATA[<p>When I first started this experiment, the prompt was simple:</p>
<blockquote><p>“Is there a WordPress plugin that lets me send the current page’s text to any email entered in a form?”</p></blockquote>
<p>From there, things evolved &#8211; quite a lot.</p>
<p>What began as a theoretical idea turned into a fully functional, bilingual plugin that detects the site language, integrates with SMTP, and securely delivers any page’s content to a recipient’s inbox.</p>
<p>This post documents how that happened.</p>
<h2>Step 1: The Initial Idea</h2>
<p>The original concept was minimalistic:</p>
<ul>
<li>Add a single input field to a WordPress page.</li>
<li>When the visitor enters an email, send the full text of that page to them.</li>
</ul>
<p>At first, I tried to use Contact Form 7 for this, but soon realized it would require too many hooks and workarounds.</p>
<p>A custom plugin would be cleaner &#8211; just one PHP file, one function, no external dependencies.</p>
<h3>Step 2: Building the Core Plugin</h3>
<p>I started by creating a folder inside wp-content/plugins/:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="swift">/wp-content/plugins/email-page-sender/
and added a file named email-page-sender.php.</pre>
<p>&nbsp;</p>
<p>The first working version looked like this:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="php">&lt;?php
/**
 * Plugin Name: Email Page Sender
 * Description: Sends the current page content to a user-provided email address.
 */

add_action('the_content', function($content) {
    if (is_page()) {
        $form = '
        &lt;form method="post" class="email-page-sender"&gt;
            &lt;input type="email" name="eps_email" placeholder="Enter your email" required&gt;
            &lt;button type="submit" name="eps_submit"&gt;Send&lt;/button&gt;
        &lt;/form&gt;';
        return $content . $form;
    }
    return $content;
});

add_action('template_redirect', function() {
    if (isset($_POST['eps_submit']) &amp;&amp; isset($_POST['eps_email'])) {
        $email = sanitize_email($_POST['eps_email']);
        if (is_email($email)) {
            global $post;
            $subject = 'Page: ' . get_the_title($post-&gt;ID);
            $body = wpautop(apply_filters('the_content', $post-&gt;post_content));
            wp_mail($email, $subject, $body);
        }
    }
});
</pre>
<p>&nbsp;</p>
<p>This minimal version worked &#8211; but only under ideal conditions.</p>
<p>If your server didn’t support PHP mail or lacked SMTP configuration, nothing was actually sent.</p>
<h2>Step 3: Adding SMTP and Proper Headers</h2>
<p>After testing, the first email failed due to Gmail’s DMARC policy:</p>
<blockquote><p>“Unauthenticated email from gmail.com is not accepted&#8230;”</p></blockquote>
<p>That’s when I integrated WP Mail SMTP and switched the “From” address to my domain (noreply@online-dentist.hu).</p>
<p>The fixed mail section became:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="php">$headers = [
  'Content-Type: text/html; charset=UTF-8',
  'From: Online Dentist &lt;noreply@online-dentist.hu&gt;',
  'Reply-To: schulmann.istvan@gmail.com'
];

$sent = wp_mail($email, $subject, $body, $headers);
</pre>
<p>&nbsp;</p>
<p>Now the email passed DMARC and SPF validation perfectly.</p>
<p>The plugin also displayed a small JavaScript alert confirming success or failure.</p>
<h3>Step 4: Handling Page Context Correctly</h3>
<p>Originally, the plugin hooked into init, but that ran before WordPress loaded the $post object &#8211;<br />
resulting in empty emails.</p>
<p>Switching to template_redirect solved this neatly:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="php">add_action('template_redirect', function() {
  // email logic here
});</pre>
<p>&nbsp;</p>
<p>At that point, $post was fully accessible, and the content sent correctly every time.</p>
<h2>Step 5: Adding Dual-Language Support</h2>
<p>My site has both Hungarian and English sections (URLs like /en/&#8230;),<br />
so I wanted the form labels and alerts to match the current language.<br />
To detect the language, I used a simple URL check:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="php">function eps_get_language() {
    $url = $_SERVER['REQUEST_URI'] ?? '';
    return (strpos($url, '/en/') !== false) ? 'en' : 'hu';
}
</pre>
<p>&nbsp;</p>
<p>Then I used this helper to localize text dynamically:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="php">$lang = eps_get_language();

if ($lang === 'en') {
    $label = 'Would you like to receive this page by email?';
    $button = 'Send';
} else {
    $label = 'Szeretnéd megkapni ezt az oldalt emailben?';
    $button = 'Küldés';
}
</pre>
<p>&nbsp;</p>
<p>and finally output the localized form:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="php">&lt;form method="post" class="email-page-sender"&gt;
    &lt;p&gt;&lt;strong&gt;&lt;?php echo esc_html($label); ?&gt;&lt;/strong&gt;&lt;/p&gt;
    &lt;input type="email" name="eps_email" placeholder="Add meg az email címet" required&gt;
    &lt;button type="submit" name="eps_submit"&gt;&lt;?php echo esc_html($button); ?&gt;&lt;/button&gt;
&lt;/form&gt;
</pre>
<p>&nbsp;</p>
<h2>Step 6: Showing Confirmation Alerts</h2>
<p>To make it user-friendly, I added success/error messages injected into the footer:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="php">add_action('wp_footer', function() use ($sent, $lang) {
    $msg = $sent
      ? ($lang === 'en' ? '<img src="https://s.w.org/images/core/emoji/17.0.2/72x72/2705.png" alt="✅" class="wp-smiley" style="height: 1em; max-height: 1em;" /> The page content has been sent!' : '<img src="https://s.w.org/images/core/emoji/17.0.2/72x72/2705.png" alt="✅" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Az oldal tartalmát elküldtem!')
      : ($lang === 'en' ? '<img src="https://s.w.org/images/core/emoji/17.0.2/72x72/26a0.png" alt="⚠" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Error sending email.' : '<img src="https://s.w.org/images/core/emoji/17.0.2/72x72/26a0.png" alt="⚠" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Hiba történt az email küldése közben.');
    echo "&lt;script&gt;alert(" . json_encode($msg) . ");&lt;/script&gt;";
});
</pre>
<p>&nbsp;</p>
<p>It’s simple, but surprisingly effective.</p>
<h3>What I Learned</h3>
<ul>
<li>Never rely on PHP’s mail() in production.&nbsp;SMTP authentication is a must, especially when using Gmail or custom domains.</li>
<li>DMARC and SPF records matter.&nbsp;Without proper DNS setup, even valid emails may bounce or be marked as spam.</li>
<li>Hook placement in WordPress is critical. init might be too early; template_redirect ensures post data is ready.</li>
<li>Internationalization doesn’t always need heavy plugins. For simple bilingual sites, even URL-based logic can be lightweight and effective.</li>
</ul>
<h3>Final Thoughts</h3>
<p>This started as a quick “can I do this?” experiment &#8211; but became a small, elegant plugin that I’ll actually use on my personal introduction pages.</p>
<p>Sometimes the most satisfying builds aren’t the big, complex systems.</p>
<p>They’re the small, human-focused touches &#8211; like letting someone you just met receive your page with one click.</p>
<p>And that’s exactly what Email Page Sender does: a tiny but polished detail in the bigger story of how I built IT.</p><p>The post <a href="https://online-dentist.hu/en/how-i-built-a-dual-language-email-page-sender-plugin-for-wordpress/">[9] How I Built a Dual-Language Email Page Sender Plugin for WordPress</a> first appeared on <a href="https://online-dentist.hu">Digital Nomad Blog</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://online-dentist.hu/en/how-i-built-a-dual-language-email-page-sender-plugin-for-wordpress/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>

<!--
Performance optimized by W3 Total Cache. Learn more: https://www.boldgrid.com/w3-total-cache/?utm_source=w3tc&utm_medium=footer_comment&utm_campaign=free_plugin

Object Caching 53/100 objects using Disk
Page Caching using Disk: Enhanced 

Page cache debug info:
Engine:             Disk: Enhanced
Cache key:          online-dentist.hu/en/tag/plugin/feed/_index_slash_ssl.xml
Creation Time:      1782680719.000s
Header info:
Last-Modified:      Sun, 28 Jun 2026 14:27:32 GMT
ETag:               "af0e43bad304924cff08abd7f66a70af"
X-Powered-By:       W3 Total Cache/2.9.4
X-Robots-Tag:       noindex, follow
Link:               <https://online-dentist.hu/wp-json/>; rel="https://api.w.org/"
Link:               <https://online-dentist.hu/wp-json/wp/v2/tags/557>; rel="alternate"; title="JSON"; type="application/json"
Content-Type:       application/rss+xml; charset=UTF-8

Database Caching 2/53 queries in 0.030 seconds using Disk

Served from: online-dentist.hu @ 2026-06-28 21:05:19 by W3 Total Cache
-->