how to send email with php mail() to zimbra?

2.6k views Asked by At

Zimbra does not receive the mail I sent with mail() function what I should I do to fix this?

I'm on live hosting with cpanel and able to send the email to Yahoo!

I don't know where the php.ini is located so I can't change the SMTP or sendmail.ini if it is required to fix the problem

here is the code for sending e-mail :

// Store Data into variable
$nama = $_POST['nama'];
$email = $_POST['email'];
$perusahaan = $_POST['perusahaan'];
$message ="nama : ".$_POST[nama]."\r\n"."E-mail : ".$_POST[email]."\r\n"."Perusahaan : ".$_POST[perusahaan]."\r\n"."Nomor Hp : ".$_POST[hp]."\r\n"."Nomor Tlp : ".$_POST[tlp]."\r\n"."Alamat 1 : ".$_POST[alamat1]."\r\n"."Alamat 2 : ".$_POST[alamat2]."\r\n"."Tipe mesin : ".$_POST[tipe]."\r\n"."pesan : ".$_POST[pesan];
$message = wordwrap($message,70);
$headers = 'From: [email protected]' . "\r\n" .
'Reply-To: [email protected]' . "\r\n" .
'X-Mailer: PHP/' . PHP_VERSION;

//Prepare Query to store data into database     
$stmt=mysqli_prepare($con,"INSERT INTO penawaran(nama,email,perusahaan,message) VALUES(?,?,?,?)");
//Bind parameter
mysqli_stmt_bind_param($stmt,"ssss",$nama,$email,$perusahaan,$message);

//Send the e-mail
if(mail("[email protected]","Penawaran",$message,$headers)) {
    echo"data berhasil di kirimkan e-mail";
} else {
    echo"data tidak berhasil dikirim ke e-mail, sayang sekali";
}
//Execute Query     
mysqli_stmt_execute($stmt);
}
1

There are 1 answers

0
YaHui Jiang On

send mail testing script, can you trying..... sendmail configure file: /etc/mail/ log: /var/log/maillog

<?php

    $subject = 'one more try'.rand();
    $headers   = array();
    $headers[] = "MIME-Version: 1.0";
    $headers[] = "Content-type: text/plain; charset=iso-8859-1";
    $headers[] = "From: [email protected]";
    $headers[] = "Subject: {$subject}";
    $headers[] = "X-Mailer: PHP/".phpversion();

    $ok = mail('[email protected]', $subject, 'the message', implode("\r\n",$headers));
    var_dump($ok);