-3

I'm using PHP, and now i found that the php native mail() method is finally also the smtp.

Ok lets say i am using very simple:

mail("david@gmail.com","hello","hello");

If this code fails, can i say it is SMTP and/or connection to SMTP Server problem?
What i want to discover finally is:

  • So can i say that, we are ONLY using smtp finally (to send) ?
  • Or, any other mail sending systems we can use (in PHP at least) ?

I'm asking this knowledge because:

  • I want to confirm that, whenever we have problems in sending mails (by using flawless coding), so that is the problem about SMTP Server & its Configurations etc. Can i say that?

Note: Please, I do not have enough knowledge in mail systems. So maybe i need a brief explanation about major different mail systems (if there is something else then smtp).

夏期劇場
  • 17,821
  • 44
  • 135
  • 217
  • What exactly is the problem you are trying to solve? There are theoretically unlimited ways of sending something from PHP, but few are practical. What is your real world issue that makes you ask this? Knowing that would make things more productive. – Pekka Oct 12 '12 at 05:59
  • How can you send emails rather then using SMTP method?? (in php) – 夏期劇場 Oct 12 '12 at 06:00
  • 1
    SMTP is the most used protocol to send mails. If you where think about POP3 or IMAP, those are protocol to receive mails. As far as I know, there aren't any good alternatives (for SMTP) – User404 Oct 12 '12 at 06:01
  • Oops sorry! I completely ignored the `NOT`. – Shiplu Mokaddim Oct 12 '12 at 06:02
  • As long as we do not know what real world problem you are trying to solve, I don't think this is a constructive way of asking questions. But yes, SMTP is *the* protocol that is used to send E-Mail on the Internet these days. There are many libraries that help with sending Mail in PHP but in the end, they all use SMTP in one way or the other. – Pekka Oct 12 '12 at 06:03
  • I'm asking this knowledge because `I want to confirm that, whenever we have problems in sending mails (by using flawless coding), so that is the problem about SMTP Server & its Configuration etc.` Can i say that? – 夏期劇場 Oct 12 '12 at 06:08
  • Any code can not be 100% flawless, there are many things related with emailing sending operation. There can be flaw at any of the related parts. You can not blindly blame SMTP server. – Shiplu Mokaddim Oct 12 '12 at 06:11
  • If you are having problems sending mail using PHP and SMTP. Try to ping / telnet your smtp server. If that fails, you have a network problem if not chances are great that there is something wrong with your server or its configuration. If your code is perfect of course. – User404 Oct 12 '12 at 06:12
  • Yes, @user1109719, so it is finally the issues related with `SMTP Server` (configuration/ connection etc). – 夏期劇場 Oct 12 '12 at 06:14
  • @4lvin If you provide your php code we can check whether your code is flawless (as you claim). Are you using a proxy? – User404 Oct 12 '12 at 06:16
  • Ok lets compromise. How about even this one? `` So is it code problem or what will you point out? – 夏期劇場 Oct 12 '12 at 06:18

1 Answers1

2

Yes, we are only using SMTP to send email. In the world there is actualy no alternative today - absoultely most of mail servers use SMTP for sending mail.

Actually, it depends on what do you need exactly. For example, if you need to send email with your PHP script and you don't want to use 'mail()'and SMTP directly on your server, you could use web-mail.

I mean if you have any email account on gmail or yahoo or whatever email-system, you can send email with web interface of the mail service. So, you could use the same web interface in your PHP script to send email.

Sure, you have to code this way in PHP (it is not like just execute some PHP-function). And, sure, after you sent your email with web interface the mail server will send it forward finally using SMTP protocol.

UPDATED

whenever we have problems in sending mails (by using flawless coding), so that is the problem about SMTP Server & its Configurations

Usually, SMTP server will send you an error message or an email with explanation what is wrong. If you have issues with mail sending, it could be not only SMTP related problems, but network configuration related issues or your hoster, or something else.

For example, many hosters blocks TCP port 25 (the port SMTP is working on). This is not an SMTP configuration issue, but hoster's firewall configuration.

So... actually it all depends on the exactly situation.

fycth
  • 3,410
  • 25
  • 37