I need to be able to send some emails out and in the past i always used mail() which never seemed to cause me to many problems but everything i read says don’t do this use a library. So i am trying to do this.
My first problem i have no idea how to get it installed on my server. I read a few tutorials but it doesn’t really explain what i am seeing.
I went to github and clicked the download → zip but the files in there don’t match anything the tutorials. Do i have to download using a git client or something?
I know this is probably a simple question but i don’t use Github and i don’t even know what i’m meant to be downloading to know if it’s correct.
any help appreciated.
That is your problem. Don’t use tutorials. I have said this time and time again and people seem to ignore this only to come back and say that the tutorials don’t give them what they want. I wonder why? Please stop using tutorials and use the code samples posted on the
Github repo. There is working code samples for every current release on there. What you need to do next time is always go to the main source first. If the main source doesn’t provide anything, then
Google it. You should always be doing this instead of Googling it and relying on those tutorials you find.
You don’t need to use
Github. The code samples tell you what you need. Since it doesn’t use
autoloading anymore, you don’t need
composer for this. Just download it from
Github and then use the code samples to guide you with what you really need. It’s very obvious what you’ll need because if you look at the code samples, it’ll tell you.
i looked at the tutorials as i didn’t want to come on here and ask how to set it up and someone say ‘have you bothered to google it’ as i figured i at least need to put in some effort to find out for myself
What i need is more of a setup guide. I just don’t understand what i need to do at the most basic level. I go here https://github.com/PHPMailer/PHPMailer and i used the green ‘clone or download’ button. But the zip file i downloaded doesn’t seem to contain things that are mentioned in using it. Am i downloading the wrong thing.
This seems simple enough but i just don’t know what i should be uploading to my server to get it to run https://github.com/PHPMailer/PHPMailer#a-simple-example the files it includes aren’t in the download zip.
I tried reading some of the readme files and it made no sense to me at all and had links to here and there.
I’m trying to do it right and not use mail() but i can see why I and other people just use that as it is so simple compared to this (or perhaps i am just being really dumb today)
I guess this would be useful to know as a starting point:-
Is there a set of files (a zip folder?) that i can download (from where?) and do they just need to be uploaded onto my server? or is there an installer that need to be run?
sorry i’m just not getting it yet…
Did you see this part on the first page you linked to:
“Alternatively, if you’re not using Composer, copy the contents of the PHPMailer folder into one of the include_path directories specified in your PHP configuration and load each class file manually:”
I should add, I haven’t tried it myself.
That is all you need. Then just include the
PHPMailer-master folder instead of
path/to/PHPMailer/. Simple as that.
This is why I said use the main source first before using Google. Because it clearly tells you everything you need in simple terms.
ah yes. I can see the /src file mentioned. I think i was getting confused as i didn’t have any folders called PHPMailer etc in the download.
@spaceshiptrooper - just seen your reply. Thank you so much for doing that. I’m not sure why i was finding that so difficult. Think i was getting bogged down in whether i needed a Git client or some complier or other. It just wasn’t sinking in.
Thanks both your help is very much appreciated.
I’ll see how i get on now. more coffee perhaps!
PHP has an awesome package manager called Composer which makes it very easy to install any PHP library. I suggest you use that instead of meddling with custom downloads and what not.
Just follow the instructions on the Downloads page on how to install it, and then in the root directory of your project run
composer require phpmailer/phpmailer
php composer.phar require phpmailer/phpmailer if that doesn’t work)
this will download PHPMailer for you and add it to an autoloader you can use in your index.php:
And then you can follow the examples without having to
require_once anything else manually, composer will take care of requiring the correct file(s) if and when needed.
thanks all i’ve now got it successfully up and running. easy when you know how
How did you do it, did you use Composer?
no just the files as @spaceshiptrooper very kindly showed how to download and the basic integration that @droopsnoot mentioned. I then used their example script. Had to remove a fair few bits as i didn’t need CC,Bcc attachments etc but was simply a case of adding in the variables.
I am now working on sanitizing all of the inputs as i’m passing variables from a form.
This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.