Mail Sent to spam in ROR - email

Mail sent to spam folder. I don't understand the problem.
Mailing Confirgation
# Don't care if the mailer can't send.
config.action_mailer.raise_delivery_errors = false
config.action_mailer.perform_deliveries = true
config.action_mailer.default_url_options = { :host => 'localhost:3000' }
#config/environments/development.rb
config.action_mailer.default :charset => "utf-8"
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
:openssl_verify_mode => 'none',
address: 'vps103.spsnetwork.net',
port: 25,
domain: 'mail.forestbankfoundation.org',
authentication: :login,
enable_starttls_auto: true,
user_name: 'no-reply#forestbankfoundation.org',
password: '********'
}
Mailer Action
class NewsLetterMailer < ActionMailer::Base
def newsletter_email(newsletter)
#newsletter = newsletter
mail(from: "no-reply#forestbankfoundation.org", to: #newsletter.email, subject: "New Letter For FBF Registartion", body: " Hello #{#newsletter.name} \n :Email: #{#newsletter.email}, \n Thank You For Registration Our News Letter" )
end
end
Can someone figure this out. I am not understanding why this will be happening?

I don't think action_mailer has something to do with it buddy. Have a look at this
Every receiving ISP is using different spam filtering techniques and
some ISP’s utilize some pretty crazy ideas to combat spam. So you will
undoubtedly have some mail filtered at some point during sending email
campaigns.

Related

Laravel Mail Ignores my send from [duplicate]

I am using Swift Mailer 406 for sending emails. I connect to my smtp.gmail.com account and then I do:
->setFrom(array($from => $fromname))
But the emails sent got the original gmail account email.
Can I change it?
gmail doesn't allow you to use random From addresses. You have to add and validate the address you'd like to use in the gmail settings:
Settings -> Accounts -> Send mail as -> Add another email address you own
$email=$entity->getEmail();
->setFrom(array('your fix adress#gmail.com' => $email))
In your Parameters.yml you should make this configuration:
parameters:
database_host: 127.0.0.1
database_port: null
database_name: your db name
database_user: root
database_password: null
mailer_transport: smtp
mailer_host: smtp.gmail.com
mailer_user: your fix adress#gmail.com
mailer_password: your password of your fix adress
mailer_port: 465
mailer_encryption: ssl
auth_mode: login
secret: 3556f3fb752a82ce0ee9c419ef793b7a707f324a
And in your contact controller you should add this to fix setfrom() function of swiftmailer:
if ($form->isValid()) {
$em = $this->getDoctrine()->getManager();
$subject = $entity->getSubject();
$name=$entity->getName();
$email=$entity->getEmail();
$body=$entity->getBody();
$message = \Swift_Message::newInstance('here')
->setSubject("Shoppify email from ".$name." Subject ".$subject)
->setFrom(array('your fix adress#gmail.com' => $email))
->setTo('your adress destionation#example.com')
->setBody($body);
$this->get('mailer')->send($message);
$em->persist($entity);
$em->flush();
return $this->redirect($this->generateUrl('email_sended'));
}

Cannot send mail using smtp.gmail.com from ONLY one specific Google account

I am not able to send mail via smtp.gmail.com for ONLY one specific Google account. When I use another Google account my VBS script sends mail successfully so I know the script is working correctly.
Both accounts have the Less Secure Apps turned ON.
I have also tried the Display Unlock Captcha multiple times.
POP and IMAP has been enabled for both accounts.
It looks like there is an issue with that particular account and I have already posted a request for support in the Gmail help forums.
https://productforums.google.com/forum/#!topic/gmail/8XFKONFbDA8
My VBS Script:
Dim emailObj
Set emailObj = CreateObject("CDO.Message")
emailObj.From = "******#gmail.com"
emailObj.To = "******#gmail.com"
emailObj.Subject = "Test Email"
emailObj.TextBody = "Testing Email Functionality"
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/smtpconnectiontimeout") = 60
emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = true
'First Account
emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendusername") = "******#gmail.com"
emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "************"
'Second Account
'emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendusername") = "******#gmail.com"
'emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "************"
emailConfig.Fields.Update
emailObj.Send
If err.number = 0 Then
Msgbox "Done"
Else
Msgbox err
End If
Account 1 Test (Not Working)
Account 2 Test (Working)
Error Message: The message could not be sent to the SMTP server. The transport error code was 0x80040217. The server response was not available
Any help would be appreciated.
I had a same error. There is an option in Google account - https://myaccount.google.com/lesssecureapps. I turned it On and it helped me.

How do I send an email from Rails using Gmail?

I'm using Rails 5 and trying to send out some emails from my dev machine using Gmail as a relay. I have this mailer file, app/mailers/user_notifier.rb
class UserNotifier < ActionMailer::Base
default from: RAILS_FROM_EMAIL
# send notification email to user about the price
def send_notification(user_notification, crypto_price)
puts "user notification: #{user_notification.id}"
#user = user_notification.user
#crypto_price = crypto_price
threshhold = user_notification.buy ? 'above' : 'below'
puts "user: #{#user.email} currency: #{#user.currency}"
mail( :to => #user.email,
:subject => sprintf(Constants::USER_NOTIFICATION_SUBJECT, crypto_price.crypto_currency.name, threshhold, PriceHelper.format_price(user_notification.price, #user.currency) ) )
end
And then I send the email from a Sidekiq worker like so
UserNotifier.send_notification(user_notification, price).deliver
Although I don't see any errors in my logs, the email is never delivered (I have checked my spam folder to verify this). Below is my config/environments/development.rb file.
# ActionMailer Config
config.action_mailer.smtp_settings = {
address: 'smtp.gmail.com',
port: 587,
domain: 'mybox.devbox.com',
user_name: 'myusertest1',
password: 'myuser99999',
authentication: 'plain',
enable_starttls_auto: true
}
config.action_mailer.delivery_method = :smtp
# change to true to allow email to be sent during development
config.action_mailer.perform_deliveries = true
config.action_mailer.raise_delivery_errors = true
config.action_mailer.default :charset => "utf-8"
Any ideas what could be going wrong or how I can troubleshoot this further?
I believe in Rails 5, the proper syntax would be UserNotifier.send_notification(user_notification, price).deliver_now
...and use full email as username.

Using CDO/SMTP/TLS in VB6 to send email smtp.office365.com mail server

I am searching for days to find out how can I set Office365 SMTP server in my VB6 application. My code is working properly with port 465 and other mail servers.
BUT it is not working with port 587 and smtp.office365.com
Is there any way I could have TLS via 587 in VB6?
Thanks
With this code, I get to send mail using CDO to Office365.
Private Message As CDO.Message
Private Attachment, Expression, Matches, FilenameMatch, i
Sub enviar_mail()
Set Message = New CDO.Message
Message.Subject = "Test Mail"
Message.From = "YourEmail#yourdomain.com"
Message.To = ""
Message.CC = ""
Message.TextBody = "my text body here"
Dim Configuration
Set Configuration = CreateObject("CDO.Configuration")
Configuration.Load -1 ' CDO Source Defaults
Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.office365.com"
Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "YourEmail#yourdomain.com"
Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "YourPass"
Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
Configuration.Fields.Update
Set Message.Configuration = Configuration
Message.Send
End Sub
This code worked for me until a few days ago when we switched ISP's (or maybe something changed coincidentally on the server side). If I specify port 587, I get a transport error and have not found the solution for that with VBA. Please let me know if this works for you and if you find a way to use 587. (Port 25 doesn't work for me either, same error.)
Public Function SMTPSend(vSendTo, vsubject As Variant, vmessage As Variant)
'This works
Set emailObj = CreateObject("CDO.Message")
emailObj.From = "name#myemail.com"
emailObj.To = vSendTo
emailObj.Subject = vsubject
emailObj.TextBody = vmessage
'emailObj.AddAttachment "c:\windows\win.ini"
Set emailConfig = emailObj.configuration
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/smtpserver") = "smtp.office365.com"
'Must exclude port if specifying SSL
'emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 587
emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendusername") = "name#myemail.com"
emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "mypassword"
emailConfig.Fields.Update
emailObj.Send
If Err.Number = 0 Then SMTPSend = True Else SMTPSend = False
End Function
There seem to be a number of posts on various forums suggesting that the CDO library doesn't work with port 587, but that's not true. I think the real issue is that SMTP services using port 587 are doing so because they require STARTTLS authentication and the http://schemas.microsoft.com/cdo/configuration/smtpusessl config option is specific to SSL, not TLS (I know, I know - not the most accurate description but it'll suffice for now).
Instead, there is another setting - http://schemas.microsoft.com/cdo/configuration/sendtls - that does support TLS, so using this with port 587 works fine:
config.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing").Value = 2 '2 = cdoSendUsingPort
config.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver").Value = "smtp.example.com"
config.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport").Value = 587
config.Fields("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate").Value = 1 '1 = cdoBasic
config.Fields("http://schemas.microsoft.com/cdo/configuration/sendusername").Value = "my_username"
config.Fields("http://schemas.microsoft.com/cdo/configuration/sendpassword").Value = "myy_very_secret_password"
config.Fields("http://schemas.microsoft.com/cdo/configuration/sendtls").Value = True
config.Fields("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout").Value = 60
config.Fields.Update()
This is what worked for me:
flds("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
flds("http://schemas.microsoft.com/cdo/configuration/smtpserver")= "smtp.office365.com"
flds("http://schemas.microsoft.com/cdo/configuration/smtpserverport")= 25
flds("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate")= 1
flds("http://schemas.microsoft.com/cdo/configuration/sendusername")= "name#myemail.com"
flds("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "mypasword"
flds("http://schemas.microsoft.com/cdo/configuration/smtpusessl")= True
flds("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout")= 60
I don't know if you could fix it, but I got it with this:
Private Sub Command1_Click()
Dim oSmtp As New EASendMailObjLib.Mail
oSmtp.LicenseCode = "TryIt"
' Set your Hotmail email address
oSmtp.FromAddr = "liveid#hotmail.com"
' Add recipient email address
oSmtp.AddRecipientEx "support#emailarchitect.net", 0
' Set email subject
oSmtp.Subject = "test email from hotmail account"
' Set email body
oSmtp.BodyText = "this is a test email sent from VB 6.0 project with hotmail"
' Hotmail SMTP server address
oSmtp.ServerAddr = "smtp.live.com"
' Hotmail user authentication should use your
' Hotmail email address as the user name.
oSmtp.UserName = "liveid#hotmail.com"
oSmtp.Password = "yourpassword"
' Set port to 25, if you want to use 587 port, please change 25 to 587
oSmtp.ServerPort = 25
' detect SSL/TLS connection automatically
oSmtp.SSL_init
MsgBox "start to send email ..."
If oSmtp.SendMail() = 0 Then
MsgBox "email was sent successfully!"
Else
MsgBox "failed to send email with the following error:" & oSmtp.GetLastErrDescription()
End If
End Sub
Font: https://www.emailarchitect.net/easendmail/kb/vb.aspx?cat=4
Remember download the library:
http://easendmail-smtp-component-net-edition.soft112.com/
Just Replace Parameters!

lua send mail with gmail account

I want to send email with my gmail account, I gave it a try, but no luck, so is anyone can give me a sample? Any suggestions would be appreciated. Thank you
I used lualogging api, the code is
require"logging.email"
logger = logging.email {
rcpt = "aaa#sina.com",
from = "bbb#gmail.com",
user = "bbb#gmail.com",
password = *****,
server = "smtp.gmail.com",
port = 587,
headers = {
rcpt = "aaa#sina.com",
from = "bbb#gmail.com",
subject = "[%level] logging.email test",
},
}
logger:error("error!")
You should look at LuaSocket, especially its SMTP module which can be used to send mail using your GMail account. You also need a SSL library, I use LuaSec which was designed to be used together with LuaSocket. This is the code I successfully used to send emails using my GMail account:
-- Michal Kottman, 2011, public domain
local socket = require 'socket'
local smtp = require 'socket.smtp'
local ssl = require 'ssl'
local https = require 'ssl.https'
local ltn12 = require 'ltn12'
function sslCreate()
local sock = socket.tcp()
return setmetatable({
connect = function(_, host, port)
local r, e = sock:connect(host, port)
if not r then return r, e end
sock = ssl.wrap(sock, {mode='client', protocol='tlsv1'})
return sock:dohandshake()
end
}, {
__index = function(t,n)
return function(_, ...)
return sock[n](sock, ...)
end
end
})
end
function sendMessage(subject, body)
local msg = {
headers = {
to = 'Your Target <target email>',
subject = subject
},
body = body
}
local ok, err = smtp.send {
from = '<your email>',
rcpt = '<target email>',
source = smtp.message(msg),
user = 'username',
password = 'password',
server = 'smtp.gmail.com',
port = 465,
create = sslCreate
}
if not ok then
print("Mail send failed", err) -- better error handling required
end
end
The code from Michal Kottman works properly but it fails (for me) when smpt server works on 587 port, using a pretty different way to accept mail to send (according wo what I read). Does anybody faced anything similar? I always obtain "wrong version number" on server working on port 587.