duanjiu4498 2011-12-12 20:03
浏览 43
已采纳

php mail()函数

I am new at php coding and dont know much about networking (I started 2 weeks ago), so please bear with me.

  1. 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.

  2. 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.

  3. 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)?

  • 写回答

2条回答 默认 最新

  • dthyxna3894 2011-12-12 20:36
    关注
    1. 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.

    2. 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.

    3. 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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法
  • ¥15 可否在不同线程中调用封装数据库操作的类
  • ¥15 微带串馈天线阵列每个阵元宽度计算