PHPMAILER SMTP non-hosted mail


#1

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.


#2

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.

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


#3

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.


#4

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!