When i try this code to send email, i get "Message has been sent successfully" but when i check my yahoo inbox and spam folder i see that mail is not delivered.
function sendmail(){
//PHPMailer Object
$mail = new PHPMailer;
//From email address and name
$mail->IsMail();
$mail->From = "[email protected]";
$mail->FromName = "Name";
//To address and name
$mail->addAddress("[email protected]", "Recepient Name");
//Send HTML or Plain Text email
$mail->isHTML(true);
$mail->Subject = "Subject Text";
$mail->Body = "<i>Mail body in HTML</i>";
$mail->AltBody = "This is the plain text version of the email content";
var_dump($mail);
if(!$mail->send())
{
echo "Mailer Error: " . $mail->ErrorInfo;
}
else
{
echo "Message has been sent successfully";
}
}
sendmail();
?>
When i var_dump($mail) to see what params are setted i get this:
object(PHPMailer)[1]
public 'Version' => string '5.2.14' (length=6)
public 'Priority' => null
public 'CharSet' => string 'iso-8859-1' (length=10)
public 'ContentType' => string 'text/html' (length=9)
public 'Encoding' => string '8bit' (length=4)
public 'ErrorInfo' => string '' (length=0)
public 'From' => string '[email protected]' (length=22)
public 'FromName' => string 'Name' (length=6)
public 'Sender' => string '' (length=0)
public 'ReturnPath' => string '' (length=0)
public 'Subject' => string 'Subject Text' (length=12)
public 'Body' => string '<i>Mail body in HTML</i>' (length=24)
public 'AltBody' => string 'This is the plain text version of the email content' (length=51)
public 'Ical' => string '' (length=0)
protected 'MIMEBody' => string '' (length=0)
protected 'MIMEHeader' => string '' (length=0)
protected 'mailHeader' => string '' (length=0)
public 'WordWrap' => int 0
public 'Mailer' => string 'mail' (length=4)
public 'Sendmail' => string '/usr/sbin/sendmail' (length=18)
public 'UseSendmailOptions' => boolean true
public 'PluginDir' => string '' (length=0)
public 'ConfirmReadingTo' => string '' (length=0)
public 'Hostname' => string '' (length=0)
public 'MessageID' => string '' (length=0)
public 'MessageDate' => string '' (length=0)
public 'Host' => string 'localhost' (length=9)
public 'Port' => int 25
public 'Helo' => string '' (length=0)
public 'SMTPSecure' => string '' (length=0)
public 'SMTPAutoTLS' => boolean true
public 'SMTPAuth' => boolean false
public 'SMTPOptions' =>
array (size=0)
empty
public 'Username' => string '' (length=0)
public 'Password' => string '' (length=0)
public 'AuthType' => string '' (length=0)
public 'Realm' => string '' (length=0)
public 'Workstation' => string '' (length=0)
public 'Timeout' => int 300
public 'SMTPDebug' => int 0
public 'Debugoutput' => string 'echo' (length=4)
public 'SMTPKeepAlive' => boolean false
public 'SingleTo' => boolean false
public 'SingleToArray' =>
array (size=0)
empty
public 'do_verp' => boolean false
public 'AllowEmpty' => boolean false
public 'LE' => string '
' (length=1)
public 'DKIM_selector' => string '' (length=0)
public 'DKIM_identity' => string '' (length=0)
public 'DKIM_passphrase' => string '' (length=0)
public 'DKIM_domain' => string '' (length=0)
public 'DKIM_private' => string '' (length=0)
public 'action_function' => string '' (length=0)
public 'XMailer' => string '' (length=0)
protected 'smtp' => null
protected 'to' =>
array (size=1)
0 =>
array (size=2)
0 => string '[email protected]' (length=22)
1 => string 'Recepient Name' (length=14)
protected 'cc' =>
array (size=0)
empty
protected 'bcc' =>
array (size=0)
empty
protected 'ReplyTo' =>
array (size=0)
empty
protected 'all_recipients' =>
array (size=1)
'[email protected]' => boolean true
protected 'RecipientsQueue' =>
array (size=0)
empty
protected 'ReplyToQueue' =>
array (size=0)
empty
protected 'attachment' =>
array (size=0)
empty
protected 'CustomHeader' =>
array (size=0)
empty
protected 'lastMessageID' => string '' (length=0)
protected 'message_type' => string '' (length=0)
protected 'boundary' =>
array (size=0)
empty
protected 'language' =>
array (size=0)
empty
protected 'error_count' => int 0
protected 'sign_cert_file' => string '' (length=0)
protected 'sign_key_file' => string '' (length=0)
protected 'sign_extracerts_file' => string '' (length=0)
protected 'sign_key_pass' => string '' (length=0)
protected 'exceptions' => boolean false
protected 'uniqueid' => string '' (length=0)
isMail()
(which is the default anyway), so your message will be sent via your local mail server. When it reports success, it means it delivered it successfully to your local mail server, not any further. To find out what happened after that, look in your mail server log file, usually/var/log/mail.log
. - Synchrosudo
? Are you on shared hosting? - Synchro