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 8747077
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T12:17:54+00:00 2026-06-13T12:17:54+00:00

So I wrote a php script that sends a user a temporary password for

  • 0

So I wrote a php script that sends a user a temporary password for when the forget their password so they can login and change it. The script works fine, and the email gets sent with all the correct information. The thing i want to change is who it is getting sent by. I want to use google email app for websites to send those emails, rather the emails are getting sent by my webserver. Here’s what the sending part of my script looks like:

$email_to = $_POST["email"];
$email_from = "Admin@domain.com";
$email_subject = "Account Information Recovery";
$email_message = "Here is your temporary password:\n\n";

$email_message .= "Password: ".$password."\n";
$email_message .= "\nPlease log into your account and immediately change your password.";

// create email headers
$headers = 'From: '.$email_from."\r\n".
'Reply-To: '.$email_from."\r\n" .
'X-Mailer: PHP/' . phpversion();
@mail($email_to, $email_subject, $email_message, $headers);

However when I receive the email, it comes from Admin@webserver. How do I use google’s email app to send these emails?

  • 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-13T12:17:55+00:00Added an answer on June 13, 2026 at 12:17 pm

    I would suggest Swiftmailer. It’s got a very nice and well-documented API, and supports all different kinds of transports.

    From the docs:

    require_once 'lib/swift_required.php';
    
    // Create the Transport
    $transport = Swift_SmtpTransport::newInstance('smtp.example.org', 25)
      ->setUsername('your username')
      ->setPassword('your password')
      ;
    
    /*
    You could alternatively use a different transport such as Sendmail or Mail:
    
    // Sendmail
    $transport = Swift_SendmailTransport::newInstance('/usr/sbin/sendmail -bs');
    
    // Mail
    $transport = Swift_MailTransport::newInstance();
    */
    
    // Create the Mailer using your created Transport
    $mailer = Swift_Mailer::newInstance($transport);
    
    // Create a message
    $message = Swift_Message::newInstance('Wonderful Subject')
      ->setFrom(array('john@doe.com' => 'John Doe'))
      ->setTo(array('receiver@domain.org', 'other@domain.org' => 'A name'))
      ->setBody('Here is the message itself')
      ;
    
    // Send the message
    $result = $mailer->send($message);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wrote a php-redirect script, that sends the user to different pages, depending on
I wrote a PHP script that retrieves values from a MySQL Query. I used
I wrote a php script that must be run on the php interpreter (Without
I'm using Dynatree for the first time and wrote a PHP script that returns
I wrote a PHP-CLI script that mixes two audio (.WAV PCM) files (with some
Can someone write a PHP script that reproduces the functionality of this linux shell
I am trying to write a PHP script that can upload multiple files. for($i=0;$i<count($_FILES['uploadimg']['name']);$i++){
I have a PHP script that deletes files. It can delete files from my
I want to write a php script that keeps the apache_log file open and
I am trying to write a PHP script that uses the pdftk app to

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.