Questions answered by this recipe
- Can I add SMTP email using my own email account from within my wiki?
- Can I use SMTP email within other pmwiki functions?
All sections are optional, you can remove those that do not apply to your recipe, and add new ones.
Instructions and a simple recipe to handle SMTP email using PHPMailer
This was something I worked up for a couple of different projects, particularly the MYDBLogin? project where I need to use email verification.
I recently wanted to add notification of certain events to my code and so I turned the code into a recipe so it is easy to drop into any PMWiki installation.
You will need to add PHPMailer to your server.
Instructions may vary for your host, but here's what I had to do:
- Log into your server via SSH.
- Navigate to the user home directory
[server]$ CD ~
- Download PHPMailer form GitHub.com
[server]$ wget https://github.com/PHPMailer/PHPMailer/archive/master.zip
- Unzip the file
[server]$ unzip master.zip
- Rename the file from PHPMailer-master to PHPMailer
[server]$ mv PHPMailer-master PHPMailer
Download this file SendMail.zipΔ
Unzip the file and edit the SendMail.php file to set the constants to match your server and email requirements.
The file is well commented to help you figure those our.
Copy the edited SendMail.php to your pmwiki/cookbook/ directory
Now, add This to your /local/config.php file:
##-- SEND MAIL PHPMailer recipe-- include_once ('cookbook/SendMail.php');
(be sure you save the config.php file to your server again.)
You can now use the function:
from other php functions inside of PMWiki
You must have PHPMailer installed on your server & Set the SendMail.php file to match your server configuration.
There are commented out parts if you want to add more details to the email messages you send.
As is, this just uses your SendMail.php for the send FROM information, so you just pass the send TO information to the function.
If you want to modify the code a little you can use PHPMailer to handle POP3 instead of SMTP.
from any PHP module in use in your PMWiki installation you can add a line like:
To do / some day / maybe
Add a Markup to allow sending of email from a wiki page - this has serious security issues so I have left it off for now.
If you have future plans or wishes for this recipe.
Change log / Release notes
If the recipe has multiple releases, then release notes can be placed here. Note that it's often easier for people to work with "release dates" instead of "version numbers".