Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4323630
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T09:01:39+00:00 2026-05-21T09:01:39+00:00

I am trying to send an email through php. I have tried sending to

  • 0

I am trying to send an email through php. I have tried sending to aol and hotmail accounts and no luck with either. Also firebug is returning me “mail sent” so i dont know what the problem is.

 $to = '$em';
 $subject = "Welcome";
 $body = "Hi,\n\nTest";
 $mail_sent = @mail($to, $subject, $body);
 echo $mail_sent ? "Mail sent" : "Mail failed";

$em is an email address drawn from a database and i have checked and $em is defiantly equal to an email address

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T09:01:39+00:00Added an answer on May 21, 2026 at 9:01 am

    You have two big problems here. Let’s break it down.

    $to = '$em';
    

    Variables are not interpolated inside of single-quoted strings. If you need to assign $to to the value inside $em, then ditch the quotes: $to = $em;

    $mail_sent = @mail($to, $subject, $body);
    echo $mail_sent ? "Mail sent" : "Mail failed";
    

    The @ is an error silencing operator. Using it is bad practice, because it stops PHP from letting you know when something goes wrong. Ditch it.

    Not that suppressing errors helps here, as mail() is functionally retarded and never actually complains when something might have gone wrong.

    Also firebug is returning me "mail sent" so i dont know what the problem is.

    When mail() returns true, as it has here, it means that PHP thinks that the mail was sent.

    That doesn’t mean it actually was sent. mail() is a black box. Once it thinks it’s succeeded, the mail is somewhere else and you have no way to check on it.

    Please look into using your web hosting provider’s SMTP server and a modern PHP mail library, like SwiftMailer. SwiftMailer is a bit more complex to use, but is pretty straight-forward to get working. The documentation is excellent.

    By using a modern mail library that doesn’t use mail, you will be able to see any errors along the way and deal with them. It will also enable you to know that your message was sent, meaning you can follow up with your hosting provider and/or email provider to determine why the message was not delivered.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi there I'm trying to send an HTML email through a PHP webform. The
I have been trying to send out html emails through a PHP mail script
I am trying to send a mail through core Php, I have created a
I'm trying to send an email through the Facebook API. I've added the application
I am trying to send an email through the result sets generated in MySQL
I am trying to send email using smtp authentication through google but I am
I am trying to send an smtp email through gmail's smtp server using the
I am trying to send an email through following code CODE Dim MyMailMessage As
I am trying to send an HTML mail through PHP, but I can't seem
I am trying to send an email via PHP mail() with attachments. The attachments

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.