Jump to content

phpmailer - FromName issues


isedeasy

Recommended Posts

I am using phpmailer to send emails from my site, the problem I have is that when I recieve an email it says its from '[email protected]' not 'websitename'.

 

Why is it not picking up what I pass into $mail->FromName?

<?php

// from included settings file
define ( "SITE_NAME", "websitename" );
define ( "ADMIN_EMAIL", "[email protected]" );
define ( "DOMAIN_NAME", "www.websitename.com" );
define ( "RUN_ON_DEVELOPMENT", TRUE );
define ( "USE_SMTP", TRUE );
define ( "SMTP_PORT", "25" );
define ( "SMTP_HOST", "**************" );
define ( "SMTP_USER", "**************" );
define ( "SMTP_PASS", "**************" );
define ( "MAIL_IS_HTML", TRUE );

//send mail function
function send_email ( $subject, $to, $body )
{
    require ( "classes/class_phpmailer.php" );

    $mail = new PHPMailer();

    //do we use SMTP?
    if ( USE_SMTP ) {
            $mail->IsSMTP();
            $mail->SMTPAuth = true;
            $mail->Host = SMTP_HOST;
            $mail->Port = SMTP_PORT;
            $mail->Password = SMTP_PASS;
            $mail->Username = SMTP_USER;
    }

    $mail->From = ADMIN_EMAIL;
    $mail->FromName = SITE_NAME; // <------------------- Can't get to work
    $mail->AddAddress( $to );
    $mail->AddReplyTo ( ADMIN_EMAIL, DOMAIN_NAME );
    $mail->Subject = $subject;
    $mail->Body = $body;
    $mail->WordWrap = 100;
    $mail->IsHTML ( MAIL_IS_HTML );
    $mail->AltBody = $body;

    if ( ! $mail->Send() ) {
            if ( RUN_ON_DEVELOPMENT ) {
                echo $mail->ErrorInfo;
            }
            return FALSE;
    }
    else {
            return TRUE;
    }
}
?>

Link to comment
https://forums.phpfreaks.com/topic/225841-phpmailer-fromname-issues/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.