PHPMAILER SMTP non-hosted mail


My aim is to receive mail from a contact form.

My email account is not hosted on Dreamhost.

I have installed composer /phpmailer using Putty and I think it’s ok. I am not familiar with these products and could very easily have made mistakes.

I have a form.htm and a mail.php file uploaded to my domain to test. However, when I click on the Send (on the form) I get an error

Warning: require(/home/MYPUTTY_USERNAME/phpmailer/vendor/autoload.php): failed to open stream: Permission denied in /MYWEBFT_USRNAME/MYDOMAINNAME/mail.php on line 5

Fatal error: require(): Failed opening required ‘/home/MYPUTTY_USRNAME/phpmailer/vendor/autoload.php’ (include_path=’.:/usr/local/lib/php:/usr/local/php5/lib/pear’) in /home/MYWEBFT_USRNAME/MYDOMAINNAME/mail.php on line 5

The autoload.php file is in the location specified.

I don’t know what the reference to Pear is. I haven’t installed it. My understanding was that I could use Pear or Phpmailer. I chose the latter.

I’m going around in circles.

Any ideas on a solution, I’d be very grateful.

Thank you.


I believe that’s just the path which includes the two folders.
The error is reporting permission denied on the mail.php file:

  • Check that that folder tree has the same owner/group as the rest of your site.
    – You’ll need a command like chown -R youruser:yourgroup /path/
    – Look at file permissions too: chmod 755 mail.php

After you get that working, make sure the config settings for SMTP include a from and reply-to that are the same, otherwise your mail server and/or recipients may refuse transactions. That’s a common gotcha. Look around for examples of configs.

(Sorry for lack of detail - I’m not at my desk)


Thank you for your reply.

The mail.php file is the file that is called from my contact form and is stored in my site folder with all my other htm files. I checked the permissions on it and added Execute (Read and Write were already added), but it made no difference. I got exactly the same error.

The line identified in the error points to the location of the autoload.php file and I have used chmod to change the permissions on this file and its parents. Autoload has -rwxrwxr-x.

I installed Phpmailer with composer and I had to log in with a different (shell) username. So the usernames are different - that is I upload my files onto my site using the FTP username and I used the Shell (Putty) one to install Phpmailer, hence the different references in the error message, Is that an issue?

I haven’t got as far as making sure the form is properly configured - it’s failing before that.

If you have any other ideas, I’d appreciate it. I feel like I’m knocking my head against a wall. I’m surprised that it seems so difficult - or perhaps its just me.


pretty clear to me the problem is with autoload.php, not with mail. you are getting to line 5 of your mail.php program so the permissions are fine there.

you say the location and permissions are correct? i would doublecheck those because that is the error that it is reporting.

with regards to your question about users, the permissions need to be appropriate for the user running the apache job (i’m assuming running apache on a linux).

to troubleshoot this problem, i would start at attempting to send mail from the command line first. (you can google that to see examples.) once you confirm that you can send email from the command line i would then relook at the problem with your form.

good luck!


Thank you for your response.

I can attempt to send from the command line in Putty or execute a php script (below) in the browser and, as expected, it does not arrive, because the email address (Hotmail) I am using is on the blocked list. This is why I need to use SMTP. I cannot find any examples of how to send SMTP from the command line and every attempt I have made has not worked and produces no log file.

Currently the example contact/php forms that I have produce a HTTP 500 error, which I don’t think is a step on from the original error. Baffled by the whole thing and can find no documentation on Dreamhost that helps. Perhaps it is easier for people using Wordpress and non-hosted email.

require ‘PHPMailerAutoload.php’;
$mail = new PHPMailer;
$mail->setFrom(‘’, ‘Your Name’);
$mail->addAddress(‘’, ‘My Friend’);
$mail->Subject = ‘First PHPMailer Message’;
$mail->Body = ‘Hi! This is my first e-mail sent through PHPMailer.’;
if(!$mail->send()) {
echo ‘Message was not sent.’;
echo 'Mailer error: ’ . $mail->ErrorInfo;
} else {
echo ‘Message has been sent.’;


This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.