In my open source and free online application, the tool allows people to send emails to their audience. For this purpose, I use java mail API and Gmail SMTP. However, when sending, the "from" address always is my account that I use to authenticate into Gmail and not the user's email address. This leads to a lot of confusion and problems.
I understand Gmail's philosophy to not allow this (to prevent abuse), but it is a serious limitation from my app's perspective.
Are there any free/ cheap online email services other than Gmail that allow programmatic interfacing and allow programs to send emails with a specified "from" address?
The hosting service for your application should provide you with a SMTP server that you should use to send emails. But as mentioned, forging From is the most common sign of spam and most likely such emails will be filtered out by spam filters or SMTP servers on the route.
Why don't you set the reply-to address for the email so that the users still reply to the correct email address?
Therefore you keep the from address as your gmail address but set the reply-to address to be the users address.
Something like:
msg.setReplyTo(new InternetAddress("someone#yahoo.com"));
Related
I want a free SMTP server via which I can send emails using Java Email API.
I would have used google or yahoo but they all show the original recipient in the from: section(which has my name in it).
I tried creating a gmail id using some generic name like myxyzapp#gmail.com but Google and Yahoo don't allow creation of email ids without mobile number(And I don't want to give this number).
So I ran to mailinator which is awesome for creating temporary email ids but in the end it is the SMTP services that I am interested in, not email IDs.
Is there any free SMTP configuration for sending emails via Mailinator or any other SMTP server service provider ?
There are a lot of smtp providers who provide free accounts, but these are shared servers which a lot of users use to send their mail, so there is a small chance these servers might be blacklisted due to spamming by free users and these free accounts have high restrictions placed on them as well. If this risk is not an issue for you I recommend , SendGrid or MailGun which provide free but limited accounts.
I successfully created a java program that can send emails from a gmail account, however, now I need to do the same with an email account using a Microsoft Exchange Server.
The difference is when I was creating the gmail application I had all the information I needed to just plug into the JavaMail API program to make it work. For example, the SMTP server is smtp.gmail.com, the port is 587, the account needs to be set to "Less secure login requirements", etc...
I do not have access to any of this information for the Exchange Server. I am wondering if this is possible to do? I would assume I probably wont be able to use the JavaMail API like I did with gmail seeing as i don't have any of the information that is required for the fields. Is there some other library out there that I can use?
If some of this sounds like I don't really know what I'm talking about it's probably because I don't. This is kind of new territory for me, and I seem to have hit a wall. Basically I just need a program that can send an email from an account hosted on a Microsoft Exchange server. Hopefully this make since. Thanks.
Ms Exchange and GMail are both email providers, they rely on the same protocol : SMTP. So your JavaMail API should also work with Exchange, provided the required features are enabled :
SMTP : should be enabled by default, unless your admin disabled it.
SMTP Authentication, or SMTP relay for your sender IP address : Some authentication mechanisms (AUTH LOGIN) are disabled by default on latest versions of Exchange. Relay also has to be configured by the admin.
The easiest way to find out your exchange server address and port is to contact your Exchange administrator. However, you can find it by yourself by :
If you're not on the exchange local network, you can try "nslookup -q=mx senderdomain.com" to find out the Exchange IP adderss
Else, you can try and follow this procedure
Once you have the Exchange IP address, confirm that SMTP delivery port (25) is opened, it should be. If relay is authorized for your IP, you should be done.
Else, test if SMTP submission port (587) is opened, that should be the one you use to send authenticated emails.
Alternatively, you can try and use Exchange Web Services API, provided it's enabled on the server. There seems to be a Microsoft JAVA libray to use EWS : ews-java-api.
I want to send an email from A to B, with HEADER and CONTENT through gmail.
How to do that by PHP?
I've specified the FROM (from#example.com), but when I receive the email, it's still from my gmail account (abc#gmail.com).
$mail->From = "from#example.com";
$mail->FromName = "Mailer";
$mail->AddAddress("abc12#163.example", "Josh Adams");// name is optional
$mail->AddReplyTo("abc12#qq.example", "Information");
How do I change the FROM part?
The short answer - you can't.
Google rewrites the From and Reply-To headers in messages you send via it's SMTP service to values which relate to your gmail account.
The SMTP feature of gmail isn't intended to be an open or relay service. If it allowed any values for the From header, it would significantly dilute Google's standing with spam services, as there would be no way to verify the credentials of the sender.
You need to consider alternatives. How are you planning to host your script/application/website when it's finished: virtually every hosting solutions (shared/vps/dedicated server) will come pre-configured with an email transfer solution: be it sendmail or postfix on *nix, or IIS on Windows.
If you are intent on using gmail then you could:
Setup a dedicated myapp#gmail.com account
If you own the domain you are supposedly sending from, use the free gmail for domains, and setup a myapp#mydomain.example account.
====
Edit June 2015
It was suggested that GMail does allow sending via different addresses. As far as I can tell, this is for sending via the GMail wep app, and utilises your existing external SMTP server, which is not relevant to the original question.
====
Edit Nov 2013
Seeing as this is still getting a trickle of votes. A quick update.
Google have withdrawn their free GMail for domains. There are plenty of other free services around. One of note is Mandrill - a one-to-one email service intended for transactional emails (e.g. ecommerce orders etc.). It's ran by MailChimp, who pretty much know all there is to know about sending email at volume. They also give you 12k/month free, which is rather nice.
This question and correct answer may be relevant:
When using Gmail for SMTP, can you set a different "from" address?
Gmail requires you to validate From addresses before sending mail as that email address. So you need to add a new sender in your personal gmail account and validate it.
Doing so will allow you to authenticate with youremail#gmail.com and send email from from#example.com
Unlike everyone else, I'll take the plunge and make the assumption that by letters you mean emails...
But I'm not sure what you are getting at when you mention that it should include "Headers and Content". Do you want to forward emails? Do you want the emails from A to appear as though they came from B's gmail account in the headers? Are you building some sort of gmail client?
The easiest way to send an email with PHP is with the mail function. This example comes straight from their documentation:
$to = 'nobody#example.com';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: webmaster#example.com' . "\r\n" .
'Reply-To: webmaster#example.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);
If you want the headers to appear from A's gmail and not to simply change the from/reply to part, you'd have to use gmail as the SMTP server. I don't know if you can set that at the script level.
The answer above are not quite correct.
You are definitely able to specify any senders as long as you own the other email address.
As the help page explains:
On your computer, open Gmail.
In the top right, click Settings.
Click the Accounts and import or Accounts tab.
In the "Send mail as" section, click Add another email address.
Enter your name and the address you want to send from.
Click Next Step and then Send verification.
For school or work accounts, enter the SMTP server (for example, smtp.gmail.com or smtp.yourschool.edu) and the username and password on that account.
Click Add Account.
Once that email is added successfully,
you can send email on the behalf of the new email address in gmail.
Google will not rewrite your from email in this way while you're sending email via Google SMTP.
You need to go to GMAIL settings and add new alias.
You will be asked SMTP information, which is basically useless, since you are using SMTP to send email, BUT the catch is that if your alias is on Google Suite domain it will be added just with simple email confirmation!
Once you have the alias there, you can change "From" header in your SMTP email.
NOTE: You cannot change the "From" address to whatever#dude.example, that's just how Gmail works and is the reason it's trusted.
If the reason you want to use gmail is because you don't want to set up an MTA (the reason you stated in a comment to this answer), you have 2 options:
If the web server is at your
home/work place; use your ISP's
smtp-server
If the web server is at a dedicated
hosting center, ask them what
smtp-server to use.
As we know if we want to enable our app on App Engine to receive emails, we need to first configure an email address of the format string#appid.appspotmail.com in web.xml file. However, I wanted to know if it is possible to use an email address of the form string#domain.com which can be used to receive emails for the application. Like you can map you appid#appspot.com to your own domain, and it works fine but wanted to know if it is possible do it for emails also somehow.
Just direct your mail server for domain.com to forward string#domain.com to string#your-appid.appspotmail.com or your-appid#appspot.com. The inbound email processor doesn't care what the original "to" address is -- it will process it regardless. You have access to the headers programmatically, so you can decide to treat it differently depending on what email it came in through, if you want.
I'm using Java to send messages from Gmail with Apache Commons Email, but it seems like it doesn't allow me to send messages from an address different from the one that I use to authenticate.
How do you send messages from a different address using Gmail and Java?
Basically, you are looking for an SMTP server which will let you send a message by spoofing the From MIME header. Well, if you can't find a hosted SMTP server online, you can always install one locally on your box. This will allow you to modify the email address of the sender to make it appear as if it is coming from gmail.
As far as I'm aware you can't. That is what is called relaying. Relaying is what the spammers use to send mail pretending to be whoever. Its a security hole. If you want to send as someone else you need to create another account.
How do you send messages from a different address using Gmail and Java?
For gmail, you most likely can't ... for obvious reasons.
In the Java case, whether you can or can't do this depends on the mail server that your Java application connects to. A mail server typically can be configured to allow this, but it has obvious issues so a responsible mail server admin is not going to allow this, except in controlled circumstances.