Php mail () from godaddy server

I use godaddy to host my site and use the default godaddy email service. Now I want to send an email using the php mail function to another email address from my 1 of my 15 email addresses of my godaddy email accounts.

How can I fix what the email will be sent from and how to put the username and password for the email address?

thanks

+4
source share
4 answers

Instead of using the mail () function, which simply calls the OS mail function (i.e. sendmail), try something like SwiftMail (a free PHP mail library). It supports many ways to send mail, including logging into your email account and sending email, just like from your own computer. You can even send an email from your gmail account if you want.

http://swiftmailer.org/

+3
source

The PHP mail function uses the mail server configured for this web host. You cannot change this. Since godaddy manages the mail server, he controls what headers he sends. You can try adding a custom From header, but I doubt it will work. It will either be modified, or flagged as spam, or rejected.

If you have 15 godaddy accounts , maybe it's time to look for a more serious hosting solution?

+7
source

I use godaddy hosting. Just keep some fields blank and send mail, this will work. see below the code that it works 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 an email address, so you can send mail through this email id.

 $mail->SetFrom(' youremail@example.co.in ', 'Contact'); 
0
source

This script fails with $ mail = new PHPMailer (); for me.

0
source

All Articles