Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9119915
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T05:30:34+00:00 2026-06-17T05:30:34+00:00

I’m having trouble setting the name that’s sent with mailings sent using the PHPMailer

  • 0

I’m having trouble setting the name that’s sent with mailings sent using the PHPMailer class.

I’ve written the following function so that it can be used in a similar way the php’s bulit in mail() function.

function pmail($to, $subject, $message, $headers = "", $attachments = "")
{
    date_default_timezone_set('Europe/London');

    require_once($_SERVER['DOCUMENT_ROOT']."/lib/inc/class.phpmailer.php");
    //include($_SERVER['DOCUMENT_ROOT']."/lib/inc/class.smtp.php"); // optional, gets called from within class.phpmailer.php if not already loaded

    $defaultEmail = "reply@example.com";
    $defaultEmailName = "Web Mailer";

    $mail = new PHPMailer();

    $mail->IsSMTP();                                // telling the class to use SMTP
    $mail->Host       = "mail.example.com";         // SMTP server
    $mail->SMTPDebug  = false;                      // enables SMTP debug information (for testing, 1 = errors and messages, 2 = messages only, false = off)
    $mail->SMTPAuth   = true;                       // enable SMTP authentication
    //$mail->SMTPSecure = "tls";                    // sets the prefix to the servier
    $mail->Host       = "mail.example.com";         // sets the SMTP server
    $mail->Port       = 25;                         // set the SMTP port for the GMAIL server
    $mail->Username   = "###";                      // SMTP account username
    $mail->Password   = "###";                      // SMTP account password
    $mail->SetFrom( ($headers['fromEmail'] != "" ? $headers['fromEmail'] : $defaultEmail), ($headers['fromName'] != "" ? $headers['fromName'] : $defaultEmailName) );
    $mail->AddReplyTo( ($headers['replyToEmail'] != "" ? $headers['replyToEmail'] : $defaultEmail), ($headers['replyToName'] != "" ? $headers['replyToName'] : $defaultEmailName) );
    $mail->AddAddress($to);
    $mail->Subject = $subject;
    $mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
    $mail->MsgHTML($message);

    foreach($attachments as $attachment) {
        //$mail->AddAttachment("images/phpmailer.gif");      // attachment example
        $mail->AddAttachment($attachment);
    }

    if(!$mail->Send()) {
        //echo "Mailer Error: ".$mail->ErrorInfo;
        return false;
    } else {
        //echo "Message sent!";
        return true;
    }
}

When testing with something like so;

pmail("test@test.com", "test email", "test message here");

Everything works fine, the from address shows up as reply@example.com in the headers as expected, however the name that I see in the inbox of the recipient is not Web Mailer its the default account associated with the user whos credentials are used to send the email.
In the headers the from name does show up as Web Mailer, but its the inbox where I want to see it

We are unable to set up more user accounts on our system to allow us to just make a new one with the desired name and email, therefore we have to send it via an existing user account.
In this case mine, and emails get sent with my name attached, but we want the name to show up as Web Mailer.

Is this even possible?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T05:30:35+00:00Added an answer on June 17, 2026 at 5:30 am

    Turns out my function does work as intended.
    Because I was receiving emails from this system to internal addresses, they all automatically had me in their address book, therefore as the address used to send out the emails was associated with my personal address, they saw my name instead of “Web Mailer”.

    When testing with an external email account the senders name is listed correctly.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I am doing a simple coin flipping experiment for class that involves flipping a
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I need a function that will clean a strings' special characters. I do NOT
I'm having trouble keeping the paragraph square between the quote marks. In firefox the
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am using JSon response to parse title,date content and thumbnail images and place

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.