PHP SMTP authentication

APD Toronto
APD Toronto used Ask the Experts™
on
Hello Experts.

What is the easiest way to send email through PHP with SMTP authentication? Is it PEAR?

BONUS: Would I be able to use it from my localhost, where I don't have a Mail server. (not mandatory)
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Fixer of Problems
Most Valuable Expert 2014
Commented:
Generally, it is PHPMailer https://github.com/PHPMailer/PHPMailer or SwiftMailer http://swiftmailer.org/.  They can be used from 'localhost' but like any email, you do have to connect to a SMTP server to send email.  They are not a substitute for a server.  By the way, Gmail does not like these programs.  Gmail wants a more sophisticated authentication.
Commented:
Fully agree with Dave - PHPMailer is extremely easy to implement and works great. I think PHPMailer supports GMail's auth via a 3rd party package nowadays...

Commented:
Also, for what it's worth, -all- SMTP clients work in the same manner, in that they run from your local computer and connect to a mail server (either remote or local), and tell the mail server about the message you want to send. Outlook, Thunderbird, PHPMailer, Swiftmailer, etc...

Just keep email delivery rules in mind (SPF, etc) so you don't accidentally get flagged as a spammer.
Become a Certified Penetration Testing Engineer

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

APD TorontoSoftware Developer

Author

Commented:
Could I get a sample script of PHP Mailer that uses a password? As well, is it safe if I have a contact form that asks for a email address to use that as the sent from so the replier can just hit "Reply"?
Dave BaldwinFixer of Problems
Most Valuable Expert 2014

Commented:
Yes, PHPMailer comes with samples, just download it.  Entering an email address to use as the From may not work so well.  The 'From' address is usually part of the authentication along with the password for that account.  Remember, these programs are not mail servers, they are methods to use mail servers instead of using the PHP mail() command.
APD TorontoSoftware Developer

Author

Commented:
Thank you guys.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial