Heroku SMTP can't sending email using - heroku

Hi i am currently having some problem with sending an email that gives me this error when i do the heroku logs:
ArgumentError (An SMTP From address is required to send a message. Set the message smtp_envelope_from, return_path, sender, or from address.):
i am currently using Mandrill by MailChimp for my mailer and also this is the code for adding it
if current_user.invite #user
set_activity(current_user, #user, "connection.request")
FriendshipMailer.requesting(current_user, #user).deliver
redirect_to user_path(#user), notice: "Successfully invited a user"
else
redirect_to user_path(#user), alert: "Error was encountered"
end
anybody can help me with this as idont know what to do also what do i add , as i am fairly new here in rails 4 and is a bit confussed by the commands, any help will be greatly appreciated and thanks!

Related

IPN simulator check always return INVALID

I'm trying to help a friend (a Grails programmer) that has a problem testing the Paypal IPN listener with IPN simulator: he get always an INVALID response to the post.
So i wrote a Ruby version of the listener using Sinatra and http gem but i got stuck me too.
Here the very short piece of code for Sinatra server:
require 'sinatra'
require 'http'
post '/' do
request.body.rewind
response = HTTP.post("https://ipnpb.sandbox.paypal.com/cgi-bin/webscr", body: "cmd=_notify-validate&#{request.body.read}")
logger.info "response word: #{response.to_s}" # INVALID
logger.info "response code: #{response.code}" # 200
end
I ran a tunnel to localhost (where Sinatra app is listening) using ngrok.
The app receive correctly the POST from the Paypal IPN simulator, add the required pair cmd=_notify-validate, return a POST. But the response is always "INVALID".
I tried to run the code on Heroku but in vain.
Any idea?
Thanks

How to get bounce emails from SparkPost without using webhooks?

We are working at the integration of our email application with SparkPost. The only issue we have is getting bounce emails from SparkPost to exclude them from future mailings. Our application retrieves bounce emails directly from the mail server. When the user uses the SparkPost SMTP settings in our software, he cannot retrieve and process bounce emails because SparkPost does not forward bounce messages to the user's bounce email address.
Webhooks will not work for us because they pull data in real time only. If our software is turned to off when the bounce email comes, the bounce will not be caught and will be lost for our software as there is no way to retrieve it at a later time.
So, please, let me know if there is a way to get bounce emails from SparkPost through API or via email just like Amazon SES does. Amazon SES simply forwards bounce emails to the email address specified by the user in our application (Return email header field in the message header).
If you cannot accept pushed data via HTTP like event webhooks or even our relay webhooks, the next best thing would be our Message Events API(https://www.sparkpost.com/api#/reference/message-events/message-events/search-for-message-events)
You could make a request to just get bounces for last hour like this:
https://api.sparkpost.com/api/v1/message-events?events=bounce,out_of_band
If you want more specific time ranges just add a from/to as well as a timezone if you need that:
https://api.sparkpost.com/api/v1/message-events?from=2015-09-10T00:00&to=2015-09-10T23:59&timezone=America/New_York
I wrote the following ruby code to get them as CSV:
require 'net/http'
require 'json'
require 'csv'
uri = URI('https://api.sparkpost.com/api/v1/message-events?events=bounce,out_of_band')
req = Net::HTTP::Get.new(uri)
req['Content-Type'] = 'application/json'
req['Authorization'] = ENV['API_KEY'] || raise('please provide API_KEY env variable')
res = Net::HTTP.start(uri.host, uri.port, use_ssl: true) do |https|
https.request(req)
end
bounces = JSON.parse(res.body)['results']
puts "#{bounces.count} bounces found"
CSV.open("bounces.csv", "wb") do |csv|
csv << %w(Timestamp Recipient Reason)
bounces.each do |bounce|
csv << [bounce['timestamp'], bounce['rcpt_to'], bounce['reason']]
end
end
Available as gist here: https://gist.github.com/schmijos/05d2f989c7a5854fe2cd31c666f61c39

Help with problem using mail in ruby

The error that I get is:
Net::SMTPFatalError: 550 5.7.1 Unable to relay for you#test.lindsaar.net
I am using mail-2.3.0
With Ruby 1.9
on windows XP.
The exact code I used is:
require 'rubygems'
require 'mail'
Mail.deliver do
from 'me#test.lindsaar.net'
to 'you#test.lindsaar.net'
subject 'Here is the image you wanted'
end
I don't understand what I am missing. Thanks for your help.
The error message comes from your SMTP server. Although this message can have many causes, it is most likely you forgot to provide the necessary authentication data to your SMTP server.
Taken from http://www.eudora.com/techsupport/kb/1593hq.html:
Most Internet Service Providers restrict access to their outgoing mail
servers to prevent SPAM from being sent through their mail servers. If
you are getting the "550 Relay Denied" error message, the outgoing
mail server cannot verify who you are and will not allow you to send
mail.
To configure Mail you have to prepare your own SMTP connection. See https://github.com/mikel/mail/wiki/Sending-email-via-google-smtp for an example.
You can get your username/password from your ISP (the one providing the SMTP server)

Post a private message to the user frined using Ruby and fb_graph gem?

I want to send a private message to a user's friend using fb_graph. In the docs I can see how to send a post in the users wall but not how to send a message on behalf of that user.
You can use Facebook Chat API to send private messages, here is an example in Ruby using xmpp4r_facebook gem:
sender_chat_id = "-#{sender_uid}#chat.facebook.com"
receiver_chat_id = "-#{receiver_uid}#chat.facebook.com"
message_body = "message body"
message_subject = "message subject"
jabber_message = Jabber::Message.new(receiver_chat_id, message_body)
jabber_message.subject = message_subject
client = Jabber::Client.new(Jabber::JID.new(sender_chat_id))
client.connect
client.auth_sasl(Jabber::SASL::XFacebookPlatform.new(client,
ENV.fetch('FACEBOOK_APP_ID'), facebook_auth.token,
ENV.fetch('FACEBOOK_APP_SECRET')), nil)
client.send(jabber_message)
client.close
Unfortunately it cannot be done; Facebook removed the functionality due to abuse (spam etc).
Please refer to: how send message facebook friend through graph api using Accessstoken
It seems that is not possible but posting to the user's wall might be an alternative: https://github.com/nov/fb_graph/issues/issue/28/#comment_591398

Ruby send mail with smtp

I'm trying to send simple email via Ruby (no rails) on OS X, with XCode (which installs Ruby.) But I'm running into a problem with my smtp server which requires the email client to check mail before sending as a form of authentication.
How can I get Ruby to authenticate with the smtp server in a "POP" fashion before I can send mail? Not download mail; I only want to send html formatted email (eventually via Applescript calling Ruby, because Applescript doesn't support smtp), but the server requires that I check mail before I send.
Edit 4/05/10:
Well, that's embarrasing. Turned out to be simpler; I was trying to make it more complex than it needed to be. Even though my mail server requires pop before smtp, this sends OK:
require 'net/smtp'
message = <<MESSAGE_END
From: Private Person <me#fromdomain.com>
To: A Test User <test#todomain.com>
Subject: SMTP e-mail test
This is a test e-mail message.
MESSAGE_END
Net::SMTP.start('mail.mydomain.com', 25) do |smtp|
smtp.send_message message,
'mark#mydomain.com',
'mark#mydomain.com'
end
Edit 4/04/10:
With this I get a 500 unrecognized command error; the pop server is responding, though.
require 'net/smtp'
require 'net/pop'
message = <<MESSAGE_END
From: Private Person <me#fromdomain.com>
To: A Test User <test#todomain.com>
Subject: SMTP e-mail test
This is a test e-mail message.
MESSAGE_END
Net::POP3.start('mail.mydomain.com', 110, 'mark#mydomain.com', 'password') do |pop|
// If this line is included,
// I get a printout of the number
// of emails on the server
// right before the error:
//
// puts pop.n_mails end
Net::SMTP.start('mail.markratledge.com',
25,
'localhost',
'mark#mydomain.com', 'password', :plain) do |smtp|
smtp.send_message message, 'mark#mydomain.com',
'mark#mydomain.com'
end
end
POP before SMTP isn't one of the authentication types supported by Net::SMTP so I think you're going to have to use Net::POP3 to do your POP3 login e.g.
require 'net/pop'
pop = Net::POP3.start(addr, port, account, password)
pop.finish
Net::POP3 is in the Standard Library so should be available anywhere that Net::SMTP is.
If that doesn't make your server happy then Net::Telnet will let you send the raw commands yourself.

Resources