LMS Canvas SMTP Configuration - email

I recently configured SMTP in LMS Canvas site. I used smtp.gmail.com as my host. I just pasted code in the outgoing_mail.yml as I mentioned below :
production:
address : "smtp.gmail.com"
port : 587
tls : true
user_name : "mymail.gmail.com"
password : "password created in google accounts"(app password)
authentication : "plain"
domain : "mydomain_name"
outgoing_address : "mymail.gmail.com"
default_name : "nandhu"
While I tested the smtp in the online test tool, the test mail is perfectly working but while I am using the above code in outgoing_mail.yml file. The mail is not sending could anybody please tell me the reason why it is not working in LMS Canvas and also denote if anything I am doing wrong.
Thanks

Related

Getting "Client was not authenticated to send anonymous mail during MAIL FROM" error from Exchange SMTP using Rust lettre library

I am writing a Rust application that will send email through an Exchange server with SMTP functionality enabled. According to Microsoft's webpage, the settings that are required are:
Server address smtp.office365.com
Port 587
StartTLS Enabled
Credentials for mail account login
These are corroborated by the POP/IMAP settings of the webmail service.
Here is my code (with some censoring):
extern crate lettre;
use self::lettre::email::EmailBuilder;
use self::lettre::transport::smtp::{SecurityLevel, SmtpTransportBuilder, SUBMISSION_PORT};
use self::lettre::transport::smtp::authentication::Mechanism;
use self::lettre::transport::EmailTransport;
pub fn send_mail() {
let email = EmailBuilder::new()
.from("my email")
.to("destination email")
.body("testing")
.subject("testing")
.build()
.unwrap();
// Connect to SMTP server
let mut transport = SmtpTransportBuilder::new(("smtp.office365.com", SUBMISSION_PORT))
.expect("Failed to create email transport")
.encrypt()
.smtp_utf8(true)
.credentials("my email", "my password")
.authentication_mechanism(Mechanism::Login)
.build();
println!("Mail transport built");
println!("{:?}", transport.send(email.clone()));
}
When I compile and run the code,it gives me this error:
Err(Permanent(Response { code: Code { severity:
PermanentNegativeCompletion, category: Unspecified3, detail: 0 },
message: ["5.7.57 SMTP; Client was not authenticated to send anonymous
mail during MAIL FROM [SYXPR01CA0106.ausprd01.prod.outlook.com]"] }))
Why is this happening?
The closest I've come in my research is an issue on GitHub in relation to the lettre library not supporting the Login authentication mechanism (which Office 365 uses); however, the codebase was updated to support Login and I am using the master branch directly from GitHub so theoretically my application should support the Login mechanism.
Edit: Forgot to mention that I attempted an EHLO to the server, but it returned a (Client:(Connection closed)) error.
I used telnet and openssl to try connecting directly to my SMTP server, where I found that AUTH LOGIN requires 3 commands; one to send the AUTH LOGIN code, one to send the username and another to send the password. I found that the lettre library implements all its AUTH commands as single commands, so this wasn't working with the server. I downloaded the source code for the library, changed the send function to do the three separate commands, recompiled my code and everything worked fine :)
My addition to the lettre code:
if (accepted_mechanisms[0] == Mechanism::Login) &&
(accepted_mechanisms.capacity() == 1) {
try_smtp!(self.client.command("AUTH LOGIN"), self);
try_smtp!(self.client.command(base64::encode_config(
&username.as_bytes(),
base64::STANDARD).as_str()), self);
try_smtp!(self.client.command(base64::encode_config(
&password.as_bytes(),
base64::STANDARD).as_str()), self);

Gitlab setup not sending email

I am trying to setup GitLab in windows azure. I followed this blog Setup GitLab in azure and it is working as charm. But I could not configure smtp mail sending through GitLab.
I have followed this settings SMTP Setup. Tried both Gmail and Zoho, with both ports 465 and 587
I am getting the following error
2016-09-21_09:44:28.55626 2016-09-21T09:44:28.556Z 13562 TID-vskyw WARN: {"class":"ActiveJob::QueueAdapters::SidekiqAdapter::JobWrapper","wrapped":"ActionMailer::DeliveryJob","queue":"mailers","args":[{"job_class":"ActionMailer::DeliveryJob","job_id":"6a954ac7-19d6-4b27-b28c-c511f25e6896","queue_name":"mailers","arguments":["DeviseMailer","confirmation_instructions","deliver_now",{"_aj_globalid":"gid://gitlab/User/1"},"tgShkQTx5e1sALoxkkGi",{"to":"<my email here>","_aj_symbol_keys":["to"]}],"locale":"en"}],"retry":true,"jid":"cbd7dc87ce4202265d1a6be7","created_at":1474450319.7324607,"enqueued_at":1474451065.2083879,"error_message":"end of file reached","error_class":"EOFError","failed_at":1474450320.9358478,"retry_count":5,"retried_at":1474451068.5555682}
2016-09-21_09:44:28.55639 2016-09-21T09:44:28.556Z 13562 TID-vskyw WARN: EOFError: end of file reached
I tried various combinations for SSL and TLS, but no luck yet!
I am using GitLab 8.11.7
Any help would be appreciated.
UPDATE:
I tried with GMail smtp and it works fine after allowing access to apps using this URL. This issue might be due to some Zoho's smtp policy
You should use the new smtp configurations
If you're installing from source and use SMTP to deliver mail, you will need to add the following line to config/initializers/smtp_settings.rb:
ActionMailer::Base.delivery_method = :smtp
As seen in https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/update/8.10-to-8.11.md#smtp-configuration
A configuration exemple for smtp_settings.rb is:
if Rails.env.production?
Rails.application.config.action_mailer.delivery_method = :smtp
ActionMailer::Base.delivery_method = :smtp
ActionMailer::Base.smtp_settings = {
address: "email.server.com",
port: 465,
user_name: "smtp",
password: "123456",
domain: "gitlab.company.com",
authentication: :login,
enable_starttls_auto: true,
openssl_verify_mode: 'peer' # See ActionMailer documentation for other possible options
}
end
You can see the sample file doc for configuring SMTP at https://gitlab.com/gitlab-org/gitlab-ce/blob/8-12-stable/config/initializers/smtp_settings.rb.sample#L13?
You can see more configuration options here http://api.rubyonrails.org/classes/ActionMailer/Base.html#class-ActionMailer::Base-label-Configuration+options

How to send email with Jenkins and an parameter address?

I'm using Jenkins and I would like to send an email after finished job. The problem I have is that I want to use the username defined before into a parameter in the configuration. I try to use then ${username} but i doesn't work. This is the error I get:
Sending e-mails to: ${username}#email.es
ERROR: Invalid Addresses
javax.mail.SendFailedException: Invalid Addresses;
nested exception is:
com.sun.mail.smtp.SMTPAddressFailedException: 550 5.1.1 <${username}#email.es>... User unknown
at com.sun.mail.smtp.SMTPTransport.rcptTo(SMTPTransport.java:1835)
at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:1098)
at javax.mail.Transport.send0(Transport.java:195)
at javax.mail.Transport.send(Transport.java:124)
at hudson.tasks.MailSender.run(MailSender.java:126)
at hudson.tasks.MailSender.execute(MailSender.java:101)
at hudson.maven.MavenModuleSetBuild$MavenModuleSetBuildExecution.cleanUp(MavenModuleSetBuild.java:1064)
at hudson.model.Run.execute(Run.java:1764)
at hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:531)
at hudson.model.ResourceController.execute(ResourceController.java:89)
at hudson.model.Executor.run(Executor.java:240)
Caused by: com.sun.mail.smtp.SMTPAddressFailedException: 550 5.1.1 <${username}#email.es>... User unknown
at com.sun.mail.smtp.SMTPTransport.rcptTo(SMTPTransport.java:1686)
... 10 more
It is not taking the value of the parameter. Is thera any plugin or way to do this ?
Thanks for your help.
instead of ${username} - use $username
Ex: $username#$domain.com
Here, username and domain are two parameters for build
(defined by selecting checkbox-This build is parameterized)
Configure Jenkins System for Email Notifications
To do this:
"Jenkins Dashboard -> Manage Jenkins -> Configure System"
At the bottom of the page- find : Email Notification
Then give email notification details
I have configured like this:
SMTP server : smtp.gmail.com
Default user e-mail suffix : #gmail.com
select checkbox USE smtp authentication
give: username (without #gmail.com) -eg: enter mike for mike#gmail.com
give your password
Select checkbox Use SSL
SMTP port : 465
try your email settings by sending a test mail
If your able to send it successfuly. its done
/* In the Build - The Build is Parameterized */
1st parameter
Name : username
Default Value : mike
2nd Parameter
Name: domain
Default Value: gmail
//Post-Build Actions - Email Notification
(able to see this only when you have Mailer plugin installed)
Recipients : $username#$domain.com
This should work ..
I 'found' the solution. With a maven project, it doesn' work with the simply Email notification inside the Build properties. I must use a plugin 'Ext-mail plugin' to do it. Thanks for all.

Send email from gmail using Telnet

I am working on windows and I have enabled telnet client
In cmd prompt:
$telnet smtp.gmail.com 587
220 mx.google.com ESMTP dk3sm50678627pbc.32 - gsmtp
$Helo
250 mx.google.com at your service
$ mail from: <myuser#gmail.com>
530 5.7.0 Must issue a STARTTLS command first. dk3sm50678627pbc.32 - gsmtp
$ STARTTLS
220 2.0.0 Ready to start TLS
$ mail from:
C:\Users\{myuser}>
Connection to host lost.
Don't know What is the problem ?
Can anyone help me out , how i can send emails from gmail server using telnet from command line >
smtp.gmail.com requires TLS. The basic telnet client that comes with windows does not know how to negotiate TLS with a server. You may want to use openssl instead, which is able to negotiate TLS. See http://www.madboa.com/geek/openssl/#cs-smtp for an example of how to do this.
The gmail smtp must use smtp auth before you sending your email. The smtp auth need username and password.
see this link blow if you can read in Chinese.
http://linxucn.blog.51cto.com/1360306/837365
Last I sugguest you use java to ask gmail smtp server to send email, It will be more easy , becasue you needn't encode the smtp auth to BASE64 or anything else.
GOGOGO, good luck :)
Put into a VBS file, ie sendmail.vbs.
Set emailObj = CreateObject("CDO.Message")
emailObj.From = "cat#gmail.com"
emailObj.To = "cat#gmail.com"
emailObj.Subject = "Test CDO"
emailObj.TextBody = "Test CDO"
emailObj.AddAttachment "c:\windows\win.ini"
Set emailConfig = emailObj.Configuration
emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.gmail.com"
emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 465
emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = true
emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendusername") = "cat"
emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "Ccat1"
emailConfig.Fields.Update
emailObj.Send
If err.number = 0 then Msgbox "Done"
At Google's web site for GMail you have to turn this feature on for CDO to work.
At your Gmail page click Settings - Accounts and Import - Other Google Account Settings - [At very bottom of page] Allow less secure apps.
Also from memory you also have to click a link in an email the first time you use it (it's been a few years).

Sending a mail with Sendgrid from a Grails 2.0 application on Heroku

I'm trying to send emails from my Grails 2.0 app via Sendgrid on Heroku but I can't find the right configuration. I keep getting "Connection refused" exceptions:
java.net.ConnectException: Connection refused
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:327)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:193)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:180)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:384)
at java.net.Socket.connect(Socket.java:546)
at java.net.Socket.connect(Socket.java:495)
at com.sun.mail.util.SocketFetcher.createSocket(SocketFetcher.java:233)
at com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:189)
at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1359)
at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:412)
at javax.mail.Service.connect(Service.java:288)
at grails.plugin.mail.MailMessageBuilder.sendMessage(MailMessageBuilder.groovy:102)
at grails.plugin.mail.MailService.sendMail(MailService.groovy:39)
at MailGrailsPlugin$_configureSendMail_closure6.doCall(MailGrailsPlugin.groovy:149)
The latest configuration I tried is the following:
grails {
mail {
host = "smtp.sendgrid.net"
port = 587
username = System.env.SENDGRID_USERNAME
password = System.env.SENDGRID_PASSWORD
props = [
"mail.smtp.protocol":"smtps",
"mail.smtp.channel":"plain",
"mail.smtp.auth":"true",
"mail.debug":"true"
]
}
}
It looks like you might have a firewall or ISP blocking port 587. Try this: http://support.sendgrid.com/entries/131119-help-smtp-port-25-is-being-blocked
Elmer Thomas, Developer Evangelist at SendGrid.com
Actually, the problem came from my Grails configuration. For some reason, my mail config was reset at some point and what I had in Config.groovy was not used. So the app tried to send emails via localhost and that didn't work. I found a workaround to this problem but I don't understand yet why it works.