I am at the beginning of php learning and I am confused about how to send e-mail with php. I checked some tutorial but nowhere wrote about where to include outgoing server data like password, username, etc. Is necessary to have PEAR Mail Package if I use mail() function? I hope my question is not too basic.
have a look at this http://phpmailer.codeworxtech.com/ it is open source code (free). You dont need mail details with php's mail() function you just put a few details in the headers section. If you use phpmailer then you can opt to use SMTP which is better and the documentation tells you all you need to know. Just remember that SMTP details for cpanel hosting are usually: server: mail.yourdomain.com username: cpanel login name password: cpanel login password. not your email account login details.
that is where I am getting confused. If you don't need mail details with php's mail(), how it know through which mail server will message be sent and if account data are from you? Or is even possible to send message without mail server through http? If so, which way is better? Thank you!
the PHP mail function uses UNIX sendmail which is not sent via SMTP. I recently moved to using the PHP mailer class because I wanted to use html and attachments etc. and found this the easiest way to do so. Also mail() is of no use if you want to know when people have supplied incorrect addresses etc. because there's no feedback. Jonathan
The mail problem of using mail() function is that the emails usually end up in the spam boxes. You'd better use some class like phpmailer.