Solved

Where are sent email messages stored when sent using PHP's mail()?

Posted on 2007-03-28
4
225 Views
Last Modified: 2013-12-16
When I use the PHP mail() function to send mail, are the sent messages stored somewhere? How can I tell if the mails were really sent? For example, on my GoDaddy server I exceeded the daily limit of mails that can be sent and I only found out by accident.
Thanks
tr5
0
Comment
Question by:tr5
  • 3
4 Comments
 
LVL 29

Expert Comment

by:TeRReF
ID: 18806339
As far as I know the emails are not stored. If you put a valid email in the from header, you'll receive a failure notification when emails didn't reach their destination (you can also add a Bcc header to achieve the same without having to adjust uyour from header)
0
 
LVL 29

Expert Comment

by:TeRReF
ID: 18806347
Of course, mail() itself returns false if the sending fails..
0
 

Author Comment

by:tr5
ID: 18806363
Is there a way to configure PHP or sendmail or both to store the mails or a keep a record somehow?
What do you mean by "adding a BCC header"?
0
 
LVL 29

Accepted Solution

by:
TeRReF earned 500 total points
ID: 18806496
Well, using a Bcc header will send you an email as well which will have the same result as saving the send emails. To be notified of any failures, you will need the from/ reply-to header(s) to make sure that any failures are reported back to you.

You can send extra headers with the fourth parameter in mail(). So, something like this:

$headers = 'From: youremail@yourserver.com' . "\r\n" .
                    'Bcc: youremail@yourserver.com';

if (mail($email, $subject, $body, $headers) === false))
  die('Error while sending mail');
0

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The purpose of this article is to demonstrate how we can use conditional statements using Python.
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now