Do I need an actual mailbox and verified email to send email with SES?
I own the domain I am trying to send from, but I do not have an account or mailbox setup (this is just a test domain, and I don't want to setup a gmail mailbox)
Is there a better way to be doing this in a test environment?
I am using the django-ses package, and sending email like this:
send_mail('Test subject', 'This is the body', 'mypersonalemail#yahoo.com',['info#mydomain.com'])
I very well may have a fundamental misunderstanding of sending email, so any help is appreciated!
In the test environment, you can send messages e-mail only to address registered in sandbox.
At first, you need to verify domain or email address to send from Amazon SES. But you don't need to verify address whom you want to send.
For example,
send_mail('Test subject', 'This is the body', 'mypersonalemail#yahoo.com',
['info#mydomain.com'])
Here, you need to verify mypersonalemail#yahoo.com at AWS SES, not info#mydomail.com.
Related
I am able to send e-mails using Python and the google libraries (googleapiclient, google_auth_oauthlib.flow, and google.auth.transport.requests). I'm trying to get an alternate "from" or "reply-to" address, and it's not working. My code for creating a message is like so:
# Returns an e-mail message suitable for submission through the gmail api.
def create_message(sender, to, subject, message_text):
message = MIMEMultipart()
message['to'] = to
#message['from'] = sender
message['from'] = 'derp#nowhere.com'
message['subject'] = subject
message.attach(MIMEText(message_text, 'html'))
return {'raw': base64.urlsafe_b64encode(message.as_string().encode()).decode()}
As you can see, I've adjusted the from attribute of the message. When this message is sent, it is from the gmail account owner, not "derp". How do I make the message come from a different address?
Add the e-mail address as whom you want to issue e-mail as a "Send Mail As" account: https://mail.google.com/mail/u/2/#settings/accounts. It is necessary for that other account to verify he has control of that e-mail address.
It appears not to be possible to "spoof" e-mails using gmail oauth without this verification process, though if you use the deprecated "less secure apps", it is still possible.
I am trying to send messages to my phone using the SMTP protocol. If I log into my Google Account (for which I've enabled less secure apps) I'm able to send a message to '5551234567#tmomail.net'. The subject and body of the email arrive on my phone as a text message.
However, when I try to do the same with Python's smtplib library, I don't get a message. Here's the code I'm using:
import smtplib
# Establish a secure session with gmail's outgoing SMTP server using your gmail account
server = smtplib.SMTP("smtp.gmail.com", 587)
server.starttls()
# the account that will send the emails
server.login('me#gmail.com', 'password')
# sendmail(from, to, msg)
server.sendmail('me#gmail.com', '5551234567#tmomail.net', 'hey there!')
Does anyone know what I can do to get the text message to come through from the smtplib? Any suggestions are very welcome!
Try to check the link below.
If seems like you for forgot
server.ehlo()
How to send an email with Gmail as provider using Python?
Please let us know if you see python message in SENT emails folder of Gmail Inbox.
If yes, try to find a differences between one you sent from browser and one you sent from python API.
After registration on our service user is sent by email with confirmation link.
But when it is sent to Gmail or other mail services it usually drops to spam.
Here is the code:
def email_user(self, subject, message, from_email=None):
send_mail(subject, message, from_email, [self.email])
def activate_email(self, email=None):
if email: self.email = email
self.is_activated = False
self.activation_code = hashlib.sha256(str(self.email) + os.urandom(256)).hexdigest()[:32]
self.save()
subject = u'Welcome to the {0}!'.format(settings.SITE_NAME)
message = render_to_string('users/emails/activation.html', {'activation_code': self.activation_code, 'site_name': settings.SITE_NAME, 'site_domain': settings.SITE_DOMAIN})
self.email_user(subject, message, settings.SITE_EMAIL)
How to add DKIM or other license to this email in order to make Google trust to our server?
We're using Zimbra mail server on our site domain.
P.S. I found this snippet: https://djangosnippets.org/snippets/1995/
Is it suitable somehow in my case or not?
Thank you!
How your mail is treated depends first and foremost on the configuration of the email server which sends the messages generated by your application, and the DNS records associated with it.
Google's guidelines for bulk senders are a great place to start. Check that your mail server (and the emails themselves) comply with the rules.
DKIM is one of these guidelines, so yes: adding DKIM signatures will help. A few other points in the guide:
"Use the same address in the 'From:' header on every bulk mail you send." If you used different From headers while testing or something, this could be the problem.
Publish an SPF record.
Publish a DMARC policy.
I'm trying to use google app engine's mail service on my site. It's showing some error whenever I visit the page that sends the email. The error says that I am using an unauthorized sender for the message. Here's the code that sends the email:
mail.send_mail(sender="myapp#appspot.gserviceaccount.com",
to=input_dict["email"],
subject="Mondays user activation",
body=content)
When I try out the site locally (using dev_appserver.py) it doesn't show the error, but it doesn't send the email (Note: I have to add the --enable_sendmail option when I try it locally). The error only shows up when I publish the site.
Does anybody know what I'm doing wrong? Thanks in advance for your help!
What is myapp#appspot.gserviceaccount.com? You might not be able to send mail from that address.
App Engine applications can send email messages on behalf of the app's
administrators, and on behalf of users with Google Accounts.
The email address of the sender, the From address. The sender address
must be one of the following types:
The address of a registered administrator for the application. You can add administrators to an application using the Administration
Console.
The address of the user for the current request signed in with a Google Account. You can determine the current user's email address
with the Users API. The user's account must be a Gmail account, or be
on a domain managed by Google Apps.
Any valid email receiving address for the app (such as xxx#APP-ID.appspotmail.com).
Any valid email receiving address of a domain account, such as support#example.com. Domain accounts are accounts outside of the
Google domain with email addresses that do not end in #gmail.com or
#APP-ID.appspotmail.com.
https://developers.google.com/appengine/docs/python/mail/sendingmail
First follow these steps
https://cloud.google.com/appengine/docs/python/mail/#who_can_send_mail
Then you need to manually add the sender email in cloud console
How to add an authorized sender
You may also have to add the email address you which to send the email from to the App Engine application settings Email API authorized senders.
See https://cloud.google.com/appengine/docs/python/mail/#Python_Sending_mail
Add the unauthorized email address as an administrator here:
https://console.developers.google.com/project/_/permissions/projectpermissions
How to send activation email with username by using django-registration.I've configured Amazon SES on server.
Here is my settings
AWSAccessKeyId='my_key'
AWSSecretKey='my_key'
EMAIL_BACKEND = 'django_ses.SESBackend`
When User trying to register. They get following error message. Will you please help me ? Thank you
NoAuthHandlerFound at /accounts/register/
No handler was ready to authenticate. 1 handlers were checked. ['HmacAuthV3Handler'] Check your credentials
I'm doing something wrong? please help
Latest UPDATE
'Check your credentials' % (len(names), str(names)))
NoAuthHandlerFound: No handler was ready to authenticate. 1 handlers were checked. ['HmacAuthV3Handler'] Check your credentials
OLD UPDATE
I've made some changes in settings.py
AWS_ACCESS_KEY_ID='my_key'
AWS_SECRET_ACCESS_KEY='my_key'
Now I'm getting following error.
BotoServerError: 400 Bad Request
<ErrorResponse xmlns="http://ses.amazonaws.com/doc/2010-12-01/">
<Error>
<Type>Sender</Type>
<Code>MessageRejected</Code>
<Message>Email address is not verified.</Message>
</Error>
<RequestId>37ceac2e-3861-11e1-acd0-19854590b66c</RequestId>
</ErrorResponse>
You need to verify the email address that you are sending the emails from before amazon will accept the emails.
From the Amazon SES page:
Verify Email Addresses: Before you can send email via Amazon SES, you need to verify that you own the address from which you’ll be sending email. To start the verification process, visit the AWS Management Console.
Before you check whether django-registration can send emails, make sure that sending emails works from the shell
./manage.py shell
from django.core.mail import send_mail
verified_address = "from#example.com"
send_mail('Subject here', 'Here is the message.', verified_address,
['to#example.com'], fail_silently=False)
Any error messages might give you a clue what to try next. If send_mail works, then django registration is probably using the wrong address.