Reply to topic
Send Email from a PHP Script Example
gilbertsavier


Joined: 25 Jun 2009
Posts: 9
Reply with quote
Hi,
The first argument to this function is the recipient, the second specifies the message's subject and the third one should contain the body. So to send a simple sample message, we could use:
Code:

    <?php
    $to = "recipient@example.com";
    $subject = "Hi!";
    $body = "Hi,\n\nHow are you?";
    if (mail($to, $subject, $body)) {
      echo("<p>Message successfully sent!</p>");
     } else {
      echo("<p>Message delivery failed...</p>");
     }
    ?>
nathacof
Forum Admin

Joined: 24 Oct 2006
Posts: 192
Location: Dover, DE
Reply with quote
I think it's important to note that just because the mail() function returns success doesn't mean your mail was delivered successfully. It is your mail server which ultimately delivers the message to the recipient.

So if mail() returns true but you're not seeing your emails go through, check your email logs to ensure the messages are being delivered as you'd expect.

I'm actually working on an SMTP mailer Extension for PHP in my spare time so that I can use the reply codes from the recipient's mail server to confirm receipt of said messages.

PHPMailer does support delivering mail directly to the recipients mail server via PHP sockets and SMTP, but I'm hoping for some speed increases by writing the same functionality in C.
Send Email from a PHP Script Example
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT  
Page 1 of 1  

  
  
 Reply to topic