SMTPÂ log in to an actual account on a mailserver and send the mail through SMTP to another mail server. If the mail server is configured correctly, your mails are sent from an actual account on a mailserver and will not wind up flagged as spam.
MailÂ sent with the mail() function is sent with sendmail in most cases. There is no authentication going on and it will almost always be flagged as spam if you use the "From:" in the extra headers.
This is because if you take a look at an original email file in say, gmail, you will see the headers that are sent. You are actually sending from firstname.lastname@example.org and not email@example.com like you had told the mail function to do. If you use SMTP and view the original the email is actually sent from firstname.lastname@example.orgYou can download SMTP class from: