I am using Robot-framework with the selenium2library for testing some web-application. The script log in and send an activation URL to some email. I use the ImapLibrary to catch the mail and read it out but I get following error.
FAIL : LookupError: unknown encoding: text/html
Can somebody help me out.
Following is the script I use
*** Settings ***
Library ImapLibrary
*** Test Cases ***
Email Verification
Open Mailbox host=imap.domain.com user=email#domain.com password=secret
${LATEST} = Wait For Email sender=noreply#domain.com timeout=300
${HTML} = Open Link From Email ${LATEST}
Should Contain ${HTML} Your email address has been updated
Close Mailbox
Multipart Email Verification
Open Mailbox host=imap.domain.com user=email#domain.com password=secret
${LATEST} = Wait For Email sender=noreply#domain.com timeout=300
${parts} = Walk Multipart Email ${LATEST}
:FOR ${i} IN RANGE ${parts}
\\ Walk Multipart Email ${LATEST}
\\ ${content-type} = Get Multipart Content Type
\\ Continue For Loop If '${content-type}' != 'text/html'
\\ ${payload} = Get Multipart Payload decode=True
\\ Should Contain ${payload} your email
\\ ${HTML} = Open Link From Email ${LATEST}
\\ Should Contain ${HTML} Your email
Close Mailbox
This fork: https://pypi.org/project/robotframework-imaplibrary2/ solves the issue. If you haven't already found a solution, this should fix it :)
At my company we use the mailosaur library to test our email from our Robot Framework tests. We use different email addresses on every test run.
We also use Mailosaur for SMS testing but in a different test suite using Cypress
Related
I currently have Rails applications that use SES to send emails. Unfortunately no matter how much code I put in my application I still get emails with invalid email addresses.
I want to use AWS to verify if I have a valid email address, meaning that the syntax is correct and does other verification like checking if the mailbox exists.
I installed the aws-sdk-rails gem in my application. I added my access_key_id and secret_access_key to config/credentials.yml.enc.
I added the following code from this awsdocs/aws-doc-sdk-examples GitHub repository to my contact form and made minor changes.
require 'aws-sdk-ses'
# Replace recipient#example.com with a "To" address.
recipient = params[:email]
error = " "
# Create a new SES resource in the us-west-2 region.
# Replace us-west-2 with the AWS Region you're using for Amazon SES.
ses = Aws::SES::Client.new(region: 'us-west-2')
# Try to verify email address.
begin
ses.verify_email_identity({
email_address: recipient
})
puts 'Email sent to ' + recipient
# If something goes wrong, display an error message.
rescue Aws::SES::Errors::ServiceError => error
puts "Email not sent. Error message: #{error}"
end
I entered an email address that AWS SES said that the mailbox didn't exist this morning. However when I ran this code it didn't produce an error as I thought it might. When I checked the Rails debug log error was blank. The region in my code is the one that I use to successfully send transactional emails from all my websites.
I couldn't find any documentation about that code that says how much verification it does for the email address.
Can I use this gem to find if email addresses exist or have other problems like SES checks when an email has a To: email address?
On the 'Sending Defaults' settings page of mandrill, there is a setting 'Send A Copy Of Every Email To This Address' field.
I would like to know 2 things: Is this sent using 'to', 'CC' or 'BCC', and if I send to X users, do I receive X emails or just 1?
I assume 'BCC' and '1' are the answers, but mandrill's test suite doesnt actually send emails, so this function isn't triggered and I cannot find any documentation on this.
Currently i have the below code in index view
<div id = "GetEmails"><%= mail_to "xyz#gmail.com" do %><strong>Send Mail</strong><% end %></div>
In runtime, I am updating the value of mailto: which consists of more than 1000
+email address
Now, when I click on "Send Mail", outlook is not getting opened by copying all the email address in To: field
But, if the number of email address are < 100, the on click of "Send Mail" I am able to copy all the email address in To: filed
Manually, I am able to copy more than 3000 email address.
How do I get copy all the email address in To line by clicking "Send Mail".
The mailto:(as any other URL) has a character limit for the URL, it's vary from browser to browser, or from E-Mail client to E-Mail client.
Please try to use JS.
You could have a HTML element with data attribute where all emails would be stored and then try this:
<div id="my-mails-storing-element-id" data-mails="person1#domain.com, person2#domain.com,person3#domain.com"></div>
var mailsDom = document.getElementById("my-mails-storing-element-id")
location.href = mailto:mailsDom.dataset.mails;
But it would be better if you create separate action in your controller to get those emails. Then you just need to make AJAX call to get mails data.
I hope it'd help you. Please let me now if it worked (I've tried with Mailspring mail client and it worked)
I'm using the Gmail API with Oauth 2 to read all of my emails and print out the subject and the date, like so:
for m in email_list:
msg = service.users().messages().get(userId="me", id=m["id"], format="full").execute()
header_list = msg["payload"]["headers"]
for i in header_list:
nameindict=i["name"]
if nameindict=="Subject":
print(i["value"])
if nameindict=="Date":
print(i["value"])
this section is pasted into the main() function of the gmail API example, found here:
https://developers.google.com/gmail/api/quickstart/python
However, there's two problems:
-Sometimes, it misses the subject. I checked the full output and found that some outputs didn't have a subject attached, but couldn't find out why.
-This doesn't seem to work with email sent from a Yahoo group. The "full" option returns a jumble of letters and numbers, but no subject or readable date and time sent. Does anyone know if this is possible, and how I can do it?
I'm trying to get a sign up form working with Devise; I'm testing it with Cucumber.
When a user signs up, I send a confirmation e-mail. Something goes wrong when running my test, though.
This is my scenario:
Scenario: Signing in via confirmation
Given there are the following users:
| email | password | unconfirmed |
| user#ticketee.com | password | true |
And "user#ticketee.com" opens the email with subject "Confirmation instructions"
And they click the first link in the email
Then I should see "Your account was successfully confirmed."
And I should see "Signed in as user#ticketee.com"
However, I get the following error:
expected there to be content "Your account was successfully confirmed. You are now signed in." in "\n Ticketee\n \n\nTicketee\nSign up\n Sign in\nResend confirmation instructions\n\n\n \n 1 error prohibited this user from being saved:\n Confirmation token is invalid\n\n\n Email\n\n \n\n Sign inSign upForgot your password?" (RSpec::Expectations::ExpectationNotMetError)
I guess the important part here is:
1 error prohibited this user from being saved:\n Confirmation token is invalid
I have tested this manually (went to sign up and clicked the confirmation link in the e-mail) and this works fine.. It's only when I test through Cucumber that I get the 'Confirmation token is invalid' message. Anyone know how I can fix this? I'd like to see my tests pass..
Thanks a lot.
EDIT: Steps asked for in the comments:
When /^(?:I|they|"([^"]*?)") opens? the email with subject "([^"]*?)"$/ do |address, subject|
open_email(address, :with_subject => subject)
end
Clicking link:
When /^(?:I|they) click the first link in the email$/ do
click_first_link_in_email
end
I just looked at the confirmation email I got and my e-mail address is parsed as a mailto: link; I changed the first link step to this:
And they follow "Confirm my account" in the email
but that didn't work either.. I'm still getting the invalid token error message.
So.. I wasted two hours on this. I had a typo.
I have the following line:
unconfirmed = attributes.delete("unconfirmed") == "true"
I forgot to put the quotes around true. Without the quotes, the test passes..
Jeez.
Thanks to everyone who put some time in helping me :)