email sender with grails mail plugin - email

im trying to send email with mail plugin in grails with the gmail account.
The email is sent successfully but i have a problem with the sender of the email
In Config.groovy
grails {
mail {
host = "smtp.gmail.com"
port = 465
username = "myacount#gmail.com"
password = "mypassword"
props = ["mail.smtp.auth":"true",
"mail.smtp.socketFactory.port":"465",
"mail.smtp.socketFactory.class":"javax.net.ssl.SSLSocketFactory",
"mail.smtp.socketFactory.fallback":"false"]
}
}
Then from my app, i call
mailService.sendMail {
to "another#gmail.com"
from "sender#gmail.com"
subject sub
body message
}
The email is sent fine to another#gmail.com, but the sender is not the sender#gmail.com but the myaccount#gmail.com. Any advice?

You can't do this in on GMail. It forces you to use the "myaccount#gmail.com", you'll need to either use a local provide, another provider all together or accept "myaccount#gmail.com".
I believe this is done on purpose to prevent people from sending spam through Gmail.

There is actually a way to change the 'from' under certain conditions, see http://support.google.com/mail/bin/answer.py?hl=en&answer=22370

While not a direct answer to the question, in case anyone else lands here looking for a way to send a human readable sender address, you can do so by specifying it as such
from: "Sender Name"

Related

Do I need a user#mydomain.com email for sending emails using Mailgun?

I am currently using Mailgun for sending emails. I have verified my domain and entered all the records correctly.
I am using laravel which provides an easy way to use mailgun for sending emails.
I have given a MAIL_FROM_ADDRESS as a gmail address eg.
MAIL_FROM_ADDRESS=user#gmail.com
MAIL_TO_ADDRESS=myaccount#gmail.com
But this is not working at all. The Mailgun logs shows email is delivered but no email is received in my gmail inbox at eg. myaccount#gmail.com
So is it because my MAIL_FROM_ADDRESS is a gmail address and not a domain email address?
The way that I've always used mail gun is that when you are in your mailgun account and click on the domain. I use the Defualt SMTP Login (under Domain Information) and that is my MAIL_FROM_ADDRESS
Here is a snippet from my code that may or may not help you. In this example I'm using a blade template for the email.
try {
Mail::send('hostconfirmationemail', ['client' => $event->client,
'user' => $event->user],
function ($mail) use ($event) {
$mail->from('postmaster#yourdomain.com', 'Mail Room');
$mail->to($event->user->email)->subject('New Lead Seminar RSVP Confirmation');
});
} catch (\Exception $e) {
return $e->getMessage();
}

Force Outlook to display from display name in header

I'm sending an email with .net SmtpClient and MailMessage. I set the from to be From: Something Else <mysmtprelay#example.com>. Note that mysmtprelay#example.com is a valid user on the domain and its display name is "My SMTP Relay".
When I get the email in Outlook 2013, the email from name is "My SMTP Relay" even if in the email header I see this From: Something Else <mysmtprelay#example.com>. Outlook ignore the Something Else display name and replace it with the domain name.
Is there a way to force Outlook to use the display name I provided in the From clause? If I send this email to gmail for example, the display name from the header is used, as expected.
Can someone help?
This is just how Exchange works: all incoming sender and recipient names are resolved against GAL. Exchange uses the default display name and SMTP address.

Email Doesn't Send(Type safe plugin for email ;version:Play 2.2.1 ,Scala 2.10.2)

I am not sure whether this piece of code should send email to an email address or not or just Mock emailer which just prints values .Can anyone tell me what I am doing wrong?
I took help from here:
https://github.com/typesafehub/play-plugins/tree/master/mailer
I am not getting any error...But didn't get anything when I check email...
application.scala
val mail = use[MailerPlugin].email
mail.setSubject("MailAPage email")
mail.setRecipient("Dummy Recipient <a.....#gmail.com>")
mail.setFrom("Six Hats <shat...#gmail.com>")
//or use a list
mail.setBcc(List("Dummy1 <d...#gmail.com>", "dummy2 <m....#gmail.com>"): _*)
//sends html
mail.sendHtml("<html>html</html>")
//sends text/text
mail.send("text")
//sends both text and html
mail.send("text", "<html>html</html>")
Should I have to do anything else ?
You would expect an exception if you can't connect to the mail server. For instance in case hostname or port is incorrectly configured.
If you are able to connect to the mail server/agent then all the errors that will happen there most probably will not reach your code.
For example if you run postfix or sendmail on localhost 25. You can connect to it and tell it to send the mail but you would not know if it did it.
It could be that your ISP is blocking outgoing SMTP traffic, and things like that. Do you use any particular mail server like gmail or the one provided by your ISP?

Mail list address visible in receivers To: field

I'm trying to set up a custom mailing list for my site.
When a user(user#bar.com) sends a mails to list#foo.com. The mail should automatically be sent to the subscribers.
Making the actual sending isn't that hard. But when the emails get delivered I get the "This message may not have been sent by..." warning.
This doesn't look to Cool.
First:
How do I prevent this message from showing (Most important)
How can I make the receiver see the list#foo.com address instead of their own. (Like google's mailing lists)
Note: The receiver should still be able to see the actual sender in the from field.
I've read some other posts on the topic, mentioning all kinds off different headers. But I Can't seem to get it to work.
I'm using PHPmailer and heres a part of my code:
<?php
include(class.phpmailer.php);
$real_to = "user#bar.com";
$mail = new PHPMailer();
$mail->IsMail();
$mail->AddReplyTo($_POST['from_mail'], $_POST['from_name']);
$mail->Host = "mail.foo.com";
$mail->From = $_POST['from_mail'];
$mail->Sender = "list#foo.com";
$mail->MessageID = $_POST['msgID'];
$mail->FromName = $_POST['from_name'];
$mail->AddAddress($listmail);
$mail->Subject = $_POST['subject'];
$mail->ContentType = $_POST['content_type'];
$mail->addCustomHeader("X-BeenThere: " . $listmail);
$mail->addCustomHeader("Precedence: list");
$mail->addCustomHeader("Precedence: list");
$mail->addCustomHeader("Envelope-To: " . "list#foo.com");
//$mail->addCustomHeader("Received: " . $_POST['received']);
$mail->Body = $_POST['body'];
$mail->Send();
?>
I'm not so sure about what is needed in php code, but here are some general mail-server tips. It is possible that some of your problem might lie in your header information or in your mail-server's configuration.
When I used our local mailserver to send messages to mailing lists, I discovered that people were not receiving mail on certain domains. When I looked through the mail server logs (hMailServer) I saw that the server on the recipient was rejecting the messages.
The problem turned out to be that my domain was missing a reverse ip lookup registration in the ISP's domain settings.
I believe this can also be the source of some mail recipients getting your messages tagged with spam notices and warnings (as your case may be).
Another point to consider is that you have a return-path address specified in your headers - this is not the same as the reply address - it is a setting used by mail-servers when they talk to each other. Check out this little troubleshooting guide.
I ended up making a cronjob that updated the mail list adding all recipients as aliases instead.
This solved all wierd message about the massage not originating from the sender. I dont know if this is a good method. But it works.
I also added a PTR reccord. Installed DKIM suport and set up a SPF reccord. This solved all spam marking.
Now the problem is solved.

cakephp emails not working

my problem is:
in the controller I have:
var $components = array('Email');
the method to send emails looks like this:
function send_emails() {
$this->Email->from = 'Somebody <somebody#example.com>';
$this->Email->to = 'Somebody Else <myspamplace#centrum.cz>';
$this->Email->subject = 'Test';
$this->Email->send('Hello message body!');
}
I am using Cake 1.3 and running it on localhost with Apache 2.2.11 and PHP5. Do you guys have any idea why it doesn't work?
When I put
$this->Email->delivery = 'debug';
in the code, it displays the email info and it seems like everything is ok.
Do you have any ideas what can be the reason why it doesn't send email?
If you're developing on a remote server, i.e. a hosting server, then that should work as it'll pick up the default email.
As you're not, you have to give the mail component some email capability. You can do this by, for example, feeding in your gmail (or whatever) smtp details, i.e. server, login, password.
/* SMTP Options for GMAIL */
$this->Email->smtpOptions = array(
'port'=>'465',
'timeout'=>'30',
'auth' => true,
'host' => 'ssl://smtp.gmail.com',
'username'=>'your_username#gmail.com',
'password'=>'your_gmail_password',
);
/* Set delivery method */
$this->Email->delivery = 'smtp';
See http://book.cakephp.org/view/1290/Sending-A-Message-Using-SMTP
If you're not sure what credentials to use, look it up in your email provider's help or faq. Typically it can be found by searching for how to set up Outlook or Thunderbird.
Are you sending from a windows server? If so, have you properly setup your MTA in the php ini? Can you send mail using the mail() function?
If you are on windows and need an MTA, hMail is great for development, note that many hosts will reject mail from your local machine a spam so don't use on production without an MX record, domain keys etc.
You need an SMTP server to send email. If you are trying to send it from your localhost, two good alternatives are:
FreeSMTP: A Windows-based tool that lets your computer act like an SMTP Server
Gmail: You can use your Gmail address for testing purposes.
You need to follow the instructions to send email using CakePHP through SMTP. You could also modify your php.ini settings to reflect the new settings.
I had the same problem, I forgot to enable ssl on my xampp server, for that it is necessary just to add(or uncomment) extension=php_openssl.dll line in your php.ini file. Hope it helps.