I'm building an internal app. I want to be able to press a button, and have the app automatically send a predefined email message to a specified email address, without the user knowing. I have access to a web-server, but I'm just not quite sure on what the best way to go about doing this is.
I'm using storyboard in xcode, this is a singleview application for the ipad.
Any suggestions are greatly appreciated.
You can create a PHP script that can do this (code below). Use a library such as ASIHTTPRequest to post the user's email address to the script and then the script will automatically send the message.
<?php
$to = $_POST["email"]; //this is the user's address; you can replace $_POST["email"] with "user#example.com" to try it out
$subject = "Subject";
$body = "Message";
$headers = "From: Name <noreply#example.com>\r\n" . "X-Mailer: php";
if (mail($to, $subject, $body, $headers)) {
//sent
}
?>
If you want to use the user's mail account that they have set up in the mail.app - you can't do that without the MFMailComposeViewController.
Solutions are:
Use some Framework or roll your own mail solution that you or the user fills with their respective mail acc data and then send mails.
or
Write a little PHP/Ruby/Java/... script that sends a mail which you can trigger via web request (i.e. REST).
SKPSMTPMessage works well for sending emails without the need for a UI.
(Make sure you add a reference to the CFNetwork.framework in your project.)
Related
I am working iOS swift project. I want to send a mail with app itself. When the user clicks the submit button inside the app the mail needs to send in background or pop will be present inside the app without navigating into the mail composer.
if MFMailComposeViewController.canSendMail() {
let mail = MFMailComposeViewController()
mail.mailComposeDelegate = self
mail.setToRecipients([ApplicationModel.sharedInstance.mailAddress])
mail.setSubject("Feedback: \(UserDefaults.Id)")
mail.setMessageBody(sendBpodyMessage(), isHTML: false)
present(mail, animated: true)
} else {
if let emailUrl = createEmailUrl(to: ApplicationModel.sharedInstance.mailAddress,
subject: "Feedback", body: sendBpodyMessage()) {
UIApplication.shared.open(emailUrl)
}
}
I refer so many answers that all were saying there is no way and apple did not have this feature. Is it possible or any other way Folks?
Most of them said to use API send into the own server. I will try it if I don’t have any option related to the above question.
Apple will not allow you to send email from the user's account without displaying a mail composer window to the user (for security reasons.) You will have to implement your own mail sending mechanism from your server if you want this (and still won't be able to send email from the user's account.)
It's not that "Apple does not have this feature." It's that it would be a huge security hole. Apple explicitly blocks third parties from sending emails from the user's account except using a mail composer, and WILL NEVER ALLOW IT.
Think about the potential for abuse if it was allowed. A spammer could release a "trojan horse" app like "flappy bird" for free: A fun, popular game. Millions of people download it. Unbeknownst to them, it starts sending out emails from their accounts, attempting to defraud their friends, or the online community at large
In a Delphi 10.4.2 VCL Application in Windows 10, I followed the TSendMail example here:
http://docwiki.embarcadero.com/CodeExamples/Sydney/en/TSendMail_(Delphi)
... to create a InternetSendMail1 action in the ActionList.
But when I execute this code:
var OK := InternetSendMail1.Execute;
CodeSite.Send('OK', OK);
OK returns True.
But nothing happens: No email is opened.
My email client Thunderbird is a regular registered MAPI mail client working perfectly for many years: For example, when I click a mailto link then a new email is created in Thunderbird etc.
So what must I do to make the InternetSendMail1 action work?
EDIT: I finally realized that what I want to do is not actually sending a mail but creating a mail with an attachment, so the user can edit it with a recipient, body, etc., and then send it after he has finished editing it. So I changed the question from "How to send a mail with TSendMail?" to "How to create a mail with TSendMail?".
I am trying to build up a Contact Us View in one iOS project, What I am trying to do is:
Put a Text Viewin a view controller, which will capture and save users' writing.
If users press send button, the view controller will send the Email or message to customer service. How to implement this or any SDK recommended?
Thanks in advance.
MFMailComposeViewController is fully dedicated for this. it has built in what you are trying to make. So don't write code to take this hassle. Let Apple do it for you. :)
place the uitextview on the storyboard, create an IBoutlet for your textview, and implement the uitextview delegate methods.
You can then use "shouldChangeTextInRange" to determine if the user has pressed enter.
You are going to need to hit a backend API to then send off the data through your mail server. if you don't have a backend server where you can code up a seamless email sending program, you can open up the mail app by using something like this:
let email = "foo#bar.com"
if let url = URL(string: "mailto:\(email)") {
UIApplication.shared.open(url)
}
Hello I have a custom URL to open an app with a link. It works in the browser. But I want to send an email that another user can click the link in the email and the app will be started. Does anybody know a solution?
It is not possible to send an email with the link (myApp://). It always shows the the link as blank text.
Or does anyone know another solution to transfer data between an app to a other users app?
I think you need to write the link in href html tag
i.e. open my app
another solution is to try to add any text after the double slash i.e. myApp://open
I am trying to use SendGrid's Event Notification App (http://sendgrid.com/documentation/display/apps/EventNotification) for emails of certain categories. The Event Notification on my SendGrid account is empty. The header I'm putting on my email is:
X-SMTPAPI: {"category":"category","filters":{"eventnotification":{"settings":{"url":"theurl"}}}}
But I'm not getting a callback on my url. A simple curl post on this given url gives me the expected output, so I'm pretty sure that should be working with SendGrid too.
Do you have any ideas on what the header should look like? I couldn't find too much documentation on the website for this specific app...
Thanks!
Here is an example of the header that I am successfully sending with my Sendgrid emails:
headers("X-SMTPAPI" => "{\"unique_args\": {\"customer_id\":\"#{customer.id}\",\"email_batch_id\":\"#{batch_id}\"}, \"category\":\"monthly_statement\"}")
Make sure you have the correct events checked under the event notification settings in Sendgrid.