Solved

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

Posted on 2007-03-28
4
233 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

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

Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
The viewer will learn how to dynamically set the form action using jQuery.
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.

690 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