Grow your CSS skills. Land your dream job.

Email Help

  • # February 12, 2013 at 6:31 am

    Hey guys, I was wondering if anyone had any experience with this. I am trying to send an email using PHP’s mail function.

    $to = ‘email@something.com';
    $subject = $topic;
    $message = $message;
    $headers = ‘From: ‘ . $name . “rn” .
    ‘Reply-To: ‘ . $email . “rn” .
    ‘X-Mailer: PHP/’ . phpversion();

    if (mail(“$to”, “$subject”, “$message”, “$headers”)) {
    echo(“

    Message successfully sent!

    “);
    } else {
    echo(“

    Message delivery failed…

    “);
    }

    I constantly get ‘Message successfully sent!’, yet I get no emails in my inbox. I have tried several recipient emails and nothing.

    # February 12, 2013 at 7:41 am

    Check your spam folder as pretty much all email clients that see an email without X-Spam headers will move it into spam straight away.

    # February 12, 2013 at 7:47 am

    I’ve been keeping an eye on that, I don’t have any emails coming through at all! Sorry I did specify inbox, but I meant any mailbox.

    # February 12, 2013 at 7:59 am

    Can you see them in your ‘Outbox’ or ‘Sent Items’?

    Obviously there must be some record of the messages being sent. If there isn’t, then regardless of any ‘Success’ message, they aren’t actually leaving the building.

    __
    # February 12, 2013 at 10:08 am

    In the code you show above, `$name` is not defined: if the “From” header you construct is blank, the email probably won’t be sent.

    Further, if you’re simply putting a name in the “From” header, the mail might be dropped anyway, since “From” requires an email address. Use an email that belongs to your domain (e.g., `noreply@example.com`).

    [`mail()`](http://php.net/mail) wouldn’t know about such a failure: all it does is submit the message to the mailing queue.

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".