DokuWiki

It's better when it's simple

User Tools

Site Tools


devel:mail

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
devel:mail [2012-10-12 10:36] – updated for new mailer class andidevel:mail [2024-02-29 14:06] (current) – Minor change 190.153.116.145
Line 1: Line 1:
 ====== Handling E-Mails in DokuWiki ====== ====== Handling E-Mails in DokuWiki ======
  
-DokuWiki contains a wrapper class around PHP's [[phpfn>mail]] function that takes care of the proper encoding of headers and body and also implements sending multipart mails (eg. with HTML body or attachements)+DokuWiki contains a wrapper class around PHP's [[phpfn>mail]] functionthat takes care of the proper encoding of headers and body and also implements sending multipart mails (eg. with HTML body or attachements)
  
 Please refer to the [[xref>Mailer]] class documentation for implementation details. Please refer to the [[xref>Mailer]] class documentation for implementation details.
Line 23: Line 23:
 ===== Using Replacements ===== ===== Using Replacements =====
  
-The ''setBody()'' function accepts key-value pairs as 3rd and 4th parameter to handle placeholder replacements. Supplying HTML replacements is optional. The HTML replacements will be merged with the text replacements, so you only need to specify those that differ from plain text.+The [[xref>setBody()]] function accepts key-value pairs as 3rd and 4th parameter to handle placeholder replacements. Supplying HTML replacements is optional. The HTML replacements will be merged with the text replacements, so you only need to specify those that differ from plain text.
  
  
Line 31: Line 31:
  
 // the plain text placeholder input // the plain text placeholder input
-$trep = array(+$trep = [
     'NAME' => 'Some Guy',     'NAME' => 'Some Guy',
-    'WEB'  => 'http://www.dokuwiki.org' +    'WEB'  => 'https://www.dokuwiki.org' 
-);+];
  
 // the HTML placeholder input that differ from the text ones // the HTML placeholder input that differ from the text ones
-$hrep = array( +$hrep = [ 
-    'WEB'  => '<a href="http://www.dokuwiki.org">DokuWiki</a>' +    'WEB'  => '<a href="https://www.dokuwiki.org/">DokuWiki</a>' 
-);+];
  
 // standard mail sending as seen above // standard mail sending as seen above
Line 45: Line 45:
 $mail->to('Some Guy <mail@example.com>'); $mail->to('Some Guy <mail@example.com>');
 $mail->subject('A test mail'); $mail->subject('A test mail');
-$mail->setBody($text, null, $trep, $hrep);+$mail->setBody($text, $trep, $hrep);
 $mail->send(); $mail->send();
 </code> </code>
 +
  
  
 ===== Checking for valid E-Mail ===== ===== Checking for valid E-Mail =====
  
-Use the simple utility function [[xref>mail_isvalid]] to check if a given address is a valid email address. The function makes use of the [[http://code.google.com/p/php-email-address-validation/|php-email-address-validation]] library.+Use the simple utility function [[xref>mail_isvalid()]] to check if a given address is a valid email address. The function makes use of the [[https://github.com/aziraphale/email-address-validator|php-email-address-validation]] library. 
 + 
devel/mail.1350030979.txt.gz · Last modified: 2012-10-12 10:36 by andi

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki