的內容,最簡單的回答你的問題將是把<?php>
標籤周圍的$google_map
變量您<a>
標籤是這樣的:
<a target="_blank" href="<?php echo $google_map; ?>">See map</span></a>
我假設你已經在你的PHP文檔的某個地方定義了這個變量,但是你不應該把硬編碼變量放到這樣的WordPress模板中。如果它是一個自定義字段,這PHP變量需要一個WordPress循環內進行印刷,該解決方案的外觀看起來更像是這樣的:
<a target="_blank" href="<?php the_field('google_map_variable_input'); ?>">See map</span></a>
如果生成的HTML電子郵件發送給自己,你需要定義更多參數比你在這裏列出的要多。這個改編自web tutorial HTML email一個基本的例子應該給你如何在PHP格式化HTML電子郵件一般意義:
<?php
// Setup sending address parameters for eventual php mail() call
$to = '[email protected]';
$subject = 'Email Update About XYZ';
$from = '[email protected]';
// To send HTML mail, the Content-type header must be set
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
// Create email headers
$headers .= 'From: '.$user_email."\r\n".
'Reply-To: '.$user_email."\r\n" .
'X-Mailer: PHP/' . phpversion();
// Create email body
// Again, assumes $google_map is defined somewhere else
$message = '<html><body>';
$message .= '<a target="_blank" href="';
$message .= $google_map;
$message .= '" style="color:#267ec8; font-size:14px; line-height:22px; font-weight:normal" color="#267ec8"><span style="color:#267ec8; font-size:14px; line-height:22px; font-weight:normal">See map</span></a>';
$message .= '</body></html>';
// Send email
if(mail($to, $subject, $message, $headers)){
echo 'Your mail has been sent successfully.';
} else{
echo 'Unable to send email. Please try again.';
}
?>
證明建立電子郵件的代碼,請.. – scaisEdge