I am new at php coding and dont know much about networking (I started 2 weeks ago), so please bear with me.
Recently I came across the mail()
function. First of all, I just wrote the simple code using mail()
without any modifications in php.ini
file, naturally it didnt work. So I googled the cause; I found that for linux in [mail function] we have to type in sendmail_path
the smtp server name. I have an account at yahoo.com so I typed smtp.mail.yahoo.com
, but this didn't seem to work. So I again googled that and came to know that smtp server of your ISP is required there. My program is a simple testing one and I would love to see the mail in the addresse's inbox as a result of php's code.
Also doesn't the apache server (which I use for responding to php code) have smtp support? What is the thing stopping it from messaging? If you feel I need to read please help me with a link.
Is there a difference between yahoo's/gmail's smtp and my isp's smtp, or is it that my isp's smtp communicates with yahoo's smtp to send mail (because though our isp change but we continue to send messages using same yahoo account)?
You misread the information. The sendmail_path directive does not expect a server name, it expects the path of the sendmail binary. Under Linux, you can't use an external SMTP server with plain mail()
function.
Apache is a web server. If offers HTTP but not any other service (such as SMTP or FTP). Perhaps you are confused with Microsoft IIS.
Not sure I understand the question but, nowadays, almost nobody allows to use his SMTP server to send third-party mail. If you want to send e-mail as @yahoo.com
you'll have to use Yahoo's SMTP server.
Some additional hints:
Linux servers normally have a local MTA (mail transport agent) installed so you don't have to deal with external SMTP services. It's not clear whether you tried sending e-mail before touching anything.
If you want to send e-mail through Yahoo or Gmail or some similar service, you'd better use some third-party PHP library like PEAR::Mail, PHPMailer or Swift Mailer. PHP does not support e-mail authentication natively.
You should contact your ISP for your SMTP server name and credentials. Many SMTP servers require valid login credentials before sending message to avoid unauthorized use by spammers.
Apache can interact with a mail server such as Sendmail, but does not have built-in support.
Please see the Sendmail website for information about installing your own SMTP server, or install using the packages provided for your OS or distribution.