Link to home
Start Free TrialLog in
Avatar of Simon Allaway
Simon AllawayFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Generate a auto response email using PHP that is from no-reply@domain.com

Hi PHP developers

I have a script that is part of my contact page on my web site. Basically the script sends a email to hosted mail box then forwards the email to a distribution group on a exchange server as shown below:

<?

$name=$_POST['customername'];
$email=$_POST['email'];
$phone=$_POST['telephone'];
$message=$_POST['message'];

$emailBody =   "Name: ".$name."\nEmail: ".$email."\nPhone: ".$phone."\n\nMessage: \n\n".$message."\n";                                

$headers = 'From: info@domain.com' . "\r\n" .
    'Reply-To: info@domain.com' . "\r\n" .
    'X-Mailer: PHP/' . phpversion();

mail('info@domain.com', 'Email from Website', $emailBody, $headers);

header('Location: ../contact-thanks.html');


What I would like to do is by pass the hosted server and delivery directly to exchange 2010 mailbox which has forwarding setup to a distribution group all ready setup on the exchange server.

I have created the mailbox web@domain.com and forwarding to the distribution group but what I would really like is the php script to send a No-reply email back to the sender thanking them etc maybe a link for more help.

Anyone got any ideas on the best way to achieve this?

In addition would I need to create a spf record to achieve this?

Thanks

Simon
Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

I'm not completely clear on what you want but I think I might have an idea.  Let me try to paraphrase...

When emails are received at a certain address, they are to be processed automatically on your server.  The automatic processing should include, inter alia, a response to the sender.  The automatic processing would include forwarding to the distribution list.

Does that capture the idea?  If so, you might want an "email pipe."
Avatar of Simon Allaway

ASKER

Hi Ray
In a nut  shell I would like to add to my php script to send a no reply email if it can be done?
You can send an email message from within a PHP script.  All contents of the email can be made up by you (that is one of the problems with email -- no accountability).  You use this function.
http://php.net/manual/en/function.mail.php

Since there are several layers of technology involved in sending email you would want to set up some tests, paying close attention to the headers that your server creates.  You can specify some of the headers, as shown in the online documentation about additional_headers.  The "From" address is one of the additional headers.

You may also want to familiarize yourself with this:
http://www.faqs.org/rfcs/rfc2822.html

If you're new to PHP and you want to get a foundation, this article can help.
https://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/A_11769-And-by-the-way-I-am-new-to-PHP.html
Hi Ray

You guessed it I have zip knowledge when it comes to PHP.  What I would like to do is capture the email address from the above field and then send a auto response to the captured email address thanking them and providing a link to a search facility I have on my web site.  So I need the capture and send email elements to be added to the above script. As it stands the script obviously already sends me an email with information from this page

http://www.merlin-estates.com/contact-us.html

Thanks

Simon
ASKER CERTIFIED SOLUTION
Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial