I\'m using godaddy for hosting my site and using default godaddy mail service. Now i want to sent email using php mail function to other email address from my 1 of my 15 em
Instead of using the mail() function, which just calls the OS mail function (i.e. sendmail), try something like SwiftMail (free PHP mail library). It support many different ways of sending mail, including logging into a mail account and sending email, just like you would do from your own computer. You could even send email from a gmail account if you wanted.
http://swiftmailer.org/
The PHP mail
function uses the mailserver configured for that webhost. You can't change that. Since godaddy controls the mailserver they control what headers it sends. You could try inserting a custom From
header but I doubt that will work. It will either get modified, flagged as spam, or rejected.
If you have 15 accounts at godaddy, perhaps it's time to look for a more serious hosting solution?
I am using godaddy hosting . Just keep some fields blank and send mail it will work . please see below code its working for me.
<?php
include("class.phpmailer.php");
function sendMail($address,$username,$body){
$mail = new PHPMailer();
$mail->IsSMTP(); // telling the class to use SMTP
//$mail->Host = "smtp.gmail.com"; // SMTP server
$mail->SMTPDebug = 1; // enables SMTP debug information (for testing)
// 1 = errors and messages
// 2 = messages only
// $mail->SMTPAuth = true; // enable SMTP authentication
// $mail->SMTPSecure = "ssl"; // sets the prefix to the servier
// $mail->Host = "smtp.gmail.com"; // sets as the SMTP server
// $mail->Port = 465; // set the SMTP port for the server
// $mail->Username = "xyz@gmail.com"; // username
// $mail->Password = "test121232"; // password
$mail->SetFrom('contact@example.co.in', 'Contact');
$mail->Subject = "Enquiry for tour and travels package";
$mail->MsgHTML($body);
$address = $address;
$mail->AddAddress($address, $username);
$mail->AddCC('contact@example.co.in');
if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message sent!";
}
}
?>
just changed from email address, so you can send mail through this email id.
$mail->SetFrom('youremail@example.co.in', 'Contact');