Created On: November 19, 2024, Last Updated On: November 19, 2024
By Ozzie Ghani3 new
Step-by-Step Guide to Set Up GoDaddy for Gmail
1. Log In to Your GoDaddy Account
2. Access Your Domain Settings
3. Add/Edit DNS Records for Email Setup
You need to set up DNS records, including MX, SPF, and optionally DKIM records, to work with Google's email services.
4. Set Up MX Records
5. Set Up SPF Record (TXT Record)
6. Set Up DKIM (DomainKeys Identified Mail)
To set up DKIM, you’ll need to enable it from your Google Workspace admin console if you are using Google Workspace.
7. Set Up DMARC Record (Optional but Recommended)
DMARC helps protect your domain from email spoofing.
8. Verify Your DNS Changes
9. Test Email Sending
from flask import Flask
from flask_mail import Mail, Message
app = Flask(__name__)
# Configure Flask-Mail
app.config['MAIL_SERVER'] = 'smtp.gmail.com' # Replace with your SMTP server
app.config['MAIL_PORT'] = 587 # Common port for TLS
app.config['MAIL_USE_TLS'] = True # Use TLS
app.config['MAIL_USE_SSL'] = False # Do not use SSL
app.config['MAIL_USERNAME'] = 'info@example.com' # Replace with your email
app.config['MAIL_PASSWORD'] = '****************q' # Replace with your email password
app.config['MAIL_DEFAULT_SENDER'] = 'Cool Company <info@example.com>' # Replace with your default sender email
app.config['MAIL_DEBUG'] = True
mail = Mail(app)
@app.route("/")
def send_email():
try:
# Print debug information
print("Attempting to send an email...")
# Create a message
msg = Message(
subject="Test Email",
sender=app.config['MAIL_DEFAULT_SENDER'],
recipients=["abc@example.com"], # Replace with the recipient's email
body="This is a test email sent from a Flask app using Flask-Mail.",
reply_to=app.config['MAIL_DEFAULT_SENDER'],
bcc=['xyz@example.com']
)
# Send the email
mail.send(msg)
print("Email sent successfully!") # Log success
return "Email sent successfully!"
except Exception as e:
# Log and return the error
print(f"Failed to send email: {str(e)}")
return f"Failed to send email: {str(e)}"
if __name__ == "__main__":
app.run(debug=True)