Python Forum
Sending email using own smtp server
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Sending email using own smtp server
#4
Use yagmail the best Pyhon email client.
import yagmail

# Replace with your SMTP server details
smtp_host = 'smtp.yourserver.com'
smtp_port = 587  # or the port your server uses
smtp_user = 'yourusername'
smtp_password = 'yourpassword'

yag = yagmail.SMTP(
    user=smtp_user,
    password=smtp_password,
    host=smtp_host,
    port=smtp_port
)

# Sending an email
yag.send(
    to='[email protected]',
    subject='Subject',
    contents='This is the body of the email'
) 
Additional Configuration:
If your server requires SSL/TLS, you can configure that by specifying the smtp_starttls parameter.
yag = yagmail.SMTP(
    user=smtp_user,
    password=smtp_password,
    host=smtp_host,
    port=smtp_port,
    smtp_starttls=True,  # Set to True if your server uses TLS
    smtp_ssl=False  # Set to True if your server uses SSL
)
robertkwild likes this post
Reply


Messages In This Thread
RE: Sending email using own smtp server - by snippsat - Jul-01-2024, 09:26 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Send email with smtp without using Mimetext mgallotti 0 1,341 Feb-01-2023, 04:43 AM
Last Post: mgallotti
  How to take the tar backup files form remote server to local server sivareddy 0 2,665 Jul-14-2021, 01:32 PM
Last Post: sivareddy
  send email smtp rwahdan 0 2,429 Jun-19-2021, 01:28 AM
Last Post: rwahdan
  Sending Out Email via Python JoeDainton123 1 6,856 Aug-31-2020, 12:54 AM
Last Post: nilamo
  Including a Variable In the HTML Tags When Sending An Email JoeDainton123 0 2,666 Aug-08-2020, 03:11 AM
Last Post: JoeDainton123
  TimeOutError when trying to initiate smtplib.SMTP thecosmos 0 4,655 Jun-19-2020, 05:30 AM
Last Post: thecosmos
  Python sockets : Client sending to the server nico31780 0 3,416 May-17-2020, 07:56 PM
Last Post: nico31780
  SMTP problem MajK 6 4,646 May-09-2020, 07:47 AM
Last Post: MajK
  Sending an email with attachment without using SMTP? PythonNPC 5 5,016 May-05-2020, 07:58 AM
Last Post: PythonNPC
  Issue with text encoding ans smtplib.SMTP.sendmail() JustSomeUsername383 1 5,455 Jul-23-2019, 03:15 PM
Last Post: JustSomeUsername383

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020