tarafından gönderilecek varsayılan değiştirmek için nasıl: php posta adresi ()

2 Cevap

i Aşağıdaki kodu var

$subject = "Subject Here";  
$headers  = 'MIME-Version: 1.0' . "\r\n";   
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
// Additional headers       
$headers .= 'From: Domain Name <domain@domain.com>' . "\r\n";           
$to = $email;
$body = '
My Message  here
';
mail($to, $subject, $body, $headers);

and it send mail correctly but when i see details in the email in gmail ... it shows

from Domain Name to myemail@myemail.com date Tue, May 25, 2010 at 12:41 PM subject my subject here mailed-by mars.myhostingcompany.net

i yerine mars.myhostingcompany.net arasında mydomain.com olmalıdır ki bölümü tarafından postalanacaktır benim kendi adres göstermek isterken

2 Cevap

PHP yapılandırırken hiçbir adres sağlanan bu olay üzerinden posta göndermek için bir varsayılan adres "sendmail_from" adında bir ayar var çünkü ben bu yüzden e-posta adresi bilgisayarlarınızın gösteren nedenini barındırma paylaşılan konum götürün kodunuzu.

Sen bu yüzden sadece (ben bu bilgisayardan kontrol edemezsiniz) bir olasılığı aklınıza gelebilecek kod uygun başlıklarını belirterek görünmektedir. E-mail adresinize çevresindeki - HTML olarak okumak için çalışıyor olabilir ve böylece hiçbir şey yok. PHP kendisi özel başlıkları değil, MTA (ileti aktarım aracısı) ayrıştırır ve PHP herhangi davranır çünkü bu, Windows makinelerde oluşabilir < > HTML olarak.

Ben (bu e-posta aldığında e-posta istemcisi adını göstermiyor çünkü) o kadar profesyonel görünmüyor fark ancak bir Windows makinede çalışan eğer bir alternatif geçiş sürece çok az başka yapabileceğiniz var posta paketi.

$subject = "Subject Here";  
$headers  = 'MIME-Version: 1.0' . "\r\n";   
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
// Additional headers       
$headers .= 'From: domain@domain.com' . "\r\n";           
$to = $email;
$body = '
My Message  here
';
mail($to, $subject, $body, $headers);

/ / FORMU SAYFA:

<form method="POST" action="mailer.php">
    <p>Please feel free to contact me on the form below or my direct email address: jkench@jasonkench.co.uk<br>
      <br><br>
      <br>
      <br>
      <br>
  </p>
    <table width="327" border="0">
      <tr>
        <td width="102">Name:</td>
        <td width="215"><input type="text" name="name" size="19"></td>
      </tr>
      <tr>
        <td>Company:
        <label for="company"></label></td>
        <td><input type="text" name="company"></td>
      </tr>
      <tr>
        <td>Email: </td>
        <td><input type="text" name="email" size="19"></td>
      </tr>
      <tr>
        <td>Telephone No:
        <label for="telephone"></label></td>
        <td><input type="text" name="telephone"></td>
      </tr>
  </table>
    <p><br>
      Enquiry:<br>
      <textarea rows="9" name="message" cols="65"></textarea>
      <br>
      <br>
      <input type="submit" value="Submit" name="submit">
    </p>
</form>

/ / PHP MAILER SAYFA

<?php
if(isset($_POST['submit'])) {

//SEND TO
// Send the completed form to the below email address:
    $to = "myemail@mydomain.co.uk"; 

//SUBJECT
// Subject of the email form:
    $subject = "Jason Kench - Web Developer";

//NAME
//POST the details entered into the name box
    $name = $_POST['name'];
//COMPANY NAME
//
    $company = $_POST['company'];
//EMAIL
//

    $email = $_POST['email'];
//TELEPHONE NUMBER
//
    $telephone = $_POST['telephone'];
//MESSAGE/ENQUIRY
    $message = $_POST['message'];

//Headers from a online site may help not sure
$headers  = 'MIME-Version: 1.0' . "\r\n";   
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
//FROM EMAIL ADDRESS:

// Additional headers to change the FROM EMAIL ADDRESS   
$headers .= 'From: Web-Contact-Form@mydomain.co.uk' . "\r\n";        



// BODY
// This is the body of the message that will be sent to my email address with their details.
    $body = "
    You have received a message from the online contact form at http://www.jasonkench.co.uk\n
    Details Below: \n \n
    From: $name\n 
    Company: $company\n
    $headers
    Email Address: $email\n
    Telephone No: $telephone\n
    Message: $message\n";
// FORM SENT
// This will alert the customer the form has been successfully sent.
    echo "Your details have been sent, I will contact you within 48 hours.";
// Use the mail function to email the following variables to my $to email address.  
    mail($to, $subject, $body, $headers);

} else {
    // Display error message if there is a problem.
    echo "Sorry there seems to be a problem. Please email me direct at: $to thank you.";
}
?>