Question

I am writing a website which will automatically generate emails to users on special occasions (e.g. the activation email after user registration). The problem is, SMTP authentication is required, but the website will be hosted on a web hosting service, which does not have Pear Mail installed. I have read many articles on the Internet, saying that either Pear Mail, PHPMailer or SwiftMailer is required for SMTP authentication. As I do not have the authority to install any of them, what can I do in the PHP scripting level if none of the above exists?

A side question is, if Pear Mail, PHPMailer or SwiftMailer is a PHP library, does it mean we can actually perform SMTP authentication by writing our own PHP code?

Added: This link (http://www.webdeveloper.com/forum/showthread.php?233847-A-Way-to-Send-SMTP-Mail-w-o-PEAR) seems to have provided a solution, but when I tried, nothing happened (no email was sent). Does it really work?

Was it helpful?

Solution

Classes like PEAR Mail, SwiftMailer of PHPMailer are all just PHP scripts, no different to your own scripts, so if you can run PHP at all, you can install and run any of these libraries without any special privileges. You don't even need shell access on your host - run the pear installer, or download the package on your dev machine, uncompress it, then upload the PHP files along with your own scripts. You only need to make sure your include paths are working for whatever location you choose to put them.

The installation mechanism described in the documentation is preferable as you can be sure it's putting everything in the right place, handling dependencies, versions etc, but so long as scripts are readable and accessible to PHP it doesn't matter how they get onto the server.

If you're lucky, you may be able to run the pear installer in your shell account, where it would hopefully install pear packages somewhere accessible to you.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top