1

i am hosting a script for one of my customers which is sending notification emails to his clients. now my customer wants that if the client email address is invalid or the message could not be delivered the script sends him a notification email.

i know that some mail servers are sending emails back if the message could not be delivered or the address is unknown or is that a function my mail server should provide? i am using sendmail and php mail function to send the emails, but i dont know how to provide a notification if a message could not be delivered....

maybe my english is not as good as i want to, otherwise i think i had find some results on google...because i think there must be a solution to this issue...

thank you for help!

kind regards

AnFi
  • 10,493
  • 3
  • 23
  • 47
swalter88
  • 1,413
  • 1
  • 11
  • 13

1 Answers1

0

If a message can't be delivered, bouncing is done automatically by the mailserver, you don't have to do that in your script. However, in most cases, php scripts by default use a envelope sender where no one actually sees the bounces (like www-data@yourhostingserver.example.net).

The solution is to configure your php script to use an existing email address as bounce adress. If you use the mail() function this can be done by adding the -f parameter. However, -f doesn't work on all hosting providers. Alternatively you can use a library like phpmailer which allows setting the sender adress.

Community
  • 1
  • 1
Gryphius
  • 75,626
  • 6
  • 48
  • 54