Gmail smtp settings for sending mail
Here are the Gmail SMTP settings for sending mail:
SMTP Server:
- Server:
smtp.gmail.com
- Port:
587
(or465
for SSL/TLS)
Authentication:
- Username: Your Gmail address (e.g.,
[email protected]
) - Password: Your Gmail password
Encryption:
- Encryption method:
TLS
(orSSL
for older versions)
Additional settings:
- From address: Your Gmail address (e.g.,
[email protected]
) - Reply-to address: Your Gmail address (e.g.,
[email protected]
) - Authentication type:
Plain Text
orLogin
Note:
- Make sure to enable "Less secure app access" in your Google Account settings if you're using 2-Step Verification. You can do this by going to your Google Account settings, clicking on "Security," and then toggling the switch next to "Less secure app access."
- If you're using a custom domain with Gmail, you may need to use a different SMTP server and settings. Contact your domain registrar or email provider for more information.
Here's an example of what the settings might look like in a mail client or programming language:
PHP (using the PHPMailer library):
<?php
require_once 'PHPMailer/PHPMailer.php';
require_once 'PHPMailer/SMTP.php';
$mail = new PHPMailer\PHPMailer\PHPMailer();
$mail->isSMTP();
$mail->Host = 'smtp.gmail.com';
$mail->Port = 587;
$mail->SMTPAuth = true;
$mail->Username = '[email protected]';
$mail->Password = 'your_password';
$mail->SMTPSecure = 'tls';
$mail->From = '[email protected]';
$mail->FromName = 'Your Name';
$mail->addAddress('[email protected]', 'Recipient Name');
$mail->Subject = 'Test email';
$mail->Body = 'This is a test email';
if (!$mail->send()) {
echo 'Error: '. $mail->ErrorInfo;
} else {
echo 'Email sent!';
}
?>
Python (using the smtplib library):
import smtplib
from email.mime.text import MIMEText
msg = MIMEText('This is a test email')
msg['Subject'] = 'Test email'
msg['From'] = '[email protected]'
msg['To'] = '[email protected]'
server = smtplib.SMTP('smtp.gmail.com', 587)
server.starttls()
server.login('[email protected]', 'your_password')
server.sendmail('[email protected]', '[email protected]', msg.as_string())
server.quit()
Remember to replace [email protected]
and your_password
with your actual Gmail address and password.