Linux mail from address

In Linux, the From address in an email is typically set using the MAILFROM environment variable or the From header in the email message.

Here are a few ways to set the From address in Linux:

  1. Using the MAILFROM environment variable: You can set the MAILFROM environment variable in your shell configuration file (e.g., ~/.bashrc or ~/.zshrc) to specify the desired From address. For example:

    export MAILFROM="[email protected]"
  2. Using the sendmail command: When sending an email using the sendmail command, you can specify the From address using the -f option. For example:

    sendmail -f "[email protected]" [email protected]
  3. Using the mail command: When sending an email using the mail command, you can specify the From address using the -s option. For example:

    mail -s "Subject" [email protected] -f "[email protected]"
  4. Using a mail client: If you're using a mail client like Mutt, Alpine, or Thunderbird, you can set the From address in the client's configuration settings.

  5. Using a script: You can also set the From address using a script that sends the email. For example, using Python and the smtplib library:

    
    import smtplib
    from email.mime.text import MIMEText

msg = MIMEText("Hello, world!") msg['From'] = "[email protected]" msg['To'] = "[email protected]" msg['Subject'] = "Hello, world!"

server = smtplib.SMTP('smtp.example.com') server.sendmail("[email protected]", "[email protected]", msg.as_string()) server.quit()


Note that the `From` address should be a valid email address that is recognized by the email server.