In my Symfony2.1 application I'm using the SwiftMailer to send emails. Since I'm in dev mode, I'm not sending emails for reals. I control the output in the toolbar provided by the Profiler.
The email I'm sending is in HTML. So, to ensure HTML output I did the following settings:
$message = \Swift_Message::newInstance()
->setContentType("text/html")
->setSubject('Conferma registrazione nuovo utente')
->setFrom('xxx#xxx.com')
->setTo($email)
->setBody($this->renderView('AcmeMessageBundle:Contact:contact_request_email.html.twig', 'text/html');
$this->get('mailer')->send($message);
I suppose all the setting for HTML emails are ok. Notwithstanding that, I see that the emails sent are not shown as HTML in the Profiler dedicated area. In particular, all the HTML tags are escaped! Why? What am I missing in the settings?
For dev it is recommended to set up something like Gmail to deal with emails
# app/config/config_dev.yml
swiftmailer:
transport: gmail
username: your_gmail_username
password: your_gmail_password
As for HTML emails, I can't tell exactly what's your problem, it could be anything. HTML emails are not easy (it's like developing for IE6), that's why a lot of devs just choose to send text emails.
Related
I am having issues with mail bouncing when sending from my own server to my own active yahoo account using JavaMail. The mails are passing SPF, DKIM and DMARC according to google mail that receives the same messages being bounced by yahoo. I can send messages from other accounts to my yahoo account without issue.
The messages send fine from my server to ZMail, GMail, Microsoft mail. Looking at the emails, the only thing that I have noticed is the message header for the Message-Id. My messages have the following header:
Message-ID: <923936395.17.1634776639078#[internally visible hostname]>
I am wondering if this header could be the problem and whether there is a way in JavaMail or in the Apache James to set the hostname or IP address that gets used in this message so that rather than using the "internally visible hostname", I can get the hostname that is externally visible. I have been searching the available documentation for Apache James and JavaMail but have not found any parameters to try in order to resolve this.
According to the Decompiled SRC of sun mail it should be possible by setting some properties for your session.
props.setProperty("mail.from", user);
props.setProperty("mail.host", host);
//props.setProperty("mail.user", user);
The Id will be updated by the save method (saveChanges()) and will trigger an new ID generation (updateHeaders() -> updateMessageID()). (Looked up in the decompiled MimeMessage.class)
Leading to the HostPart called in javax.mail.internet.InternetAddress.
The relevant method is _getLocalAddress.
Here you can see that the values get extracted from the Properties or will fallback to your local machine.
Used Fields:
user.name
mail.from
mail.user
mail.host
The user.name property can also be looked up from the system props.
Tried many times but no luck... I don't where the problem. Required help in solving the above code.
//SEND MAIL
$mymail=file_get_contents("mailaddress.txt");
$frommail=file_get_contents('CCmail.txt');
$to = $mymail;
$subject = "User details";
$txt = "<b>USER DETAILS</b>\r\n\r\nName: $fname\r\nEmail: $email\r\nContact no: $mobile\r\nProvince: $city $state\r\n Gender: $gender\r\nComment: $comment\r\n\r\n<b>QUESTION & ANSWERS</b>\r\n\r\nGender: $selectedgender\r\nSleeping Hours: $sleep\r\nWorking Hours: $work\r\nWeight & Height: $weightheight\r\nIllness: $illness\r\nAllergies: $allergies\r\nSweating: $sweating\r\nAge: $age\r\nSpecial Care: $care\r\nSleeping Position: $sleepingposition\r\nLevel Of Comfort: $comfort\r\nPreference: $preference\r\n";
$headers = "From: $frommail" . "\r\n" .
"CC: $frommail";
wp_mail($to,$subject,$txt,$headers);
echo"successfull";
}
}
else{
echo"Not Allowed";
}
?>
For WordPress (or indeed for any software) to send email messages it needs to have access to a Simple Mail Transfer Protocol (SMTP) server somewhere on the Internet.
The best way to do this is to
install a WordPress plugin like WP Mail SMTP. It takes over from php's rudimentary built-in SMTP handler. It also provides a plugin settings screen where you can configure your email settings.
get yourself an account on one of the SMTP services mentioned in the plugin's documentation. I like sendgrid.com for this purpose, because it has a free tier allowing up to 100 messages a day forever.
You could use the SMTP server belonging to your own email provider. But the big providers like gmail and yahoo really don't like automated email systems sending email through them, and they may refuse connections from your WordPress instance. They especially don't like incorrectly formatted email messages: the kind you might send while debugging your application. They're trying to resist attacks from spammers and cybercreeps.
Write and test your code sending only to email accounts under your control (avoiding developer spam to unsuspecting people).
A word to the wise: many countries prohibit "protected health information" -- data about medical patients -- in email messages. It's impossible to guarantee the confidentiality of email due to the way it works.
In the USA it's even illegal for a hospital or doctor to send ANY email to a patient without that patient's consent: the From: and To: fields of the email identify the recipient as a patient of the sender. Respect your patients' confidentiality!
Please tell me how to solve the problem.
The site is on Wordpress, the page has several modals with forms.
They all work well. I need to configure adding an email to the Sendpulse address book, which the user enters into the field.
Installed the sendpulse package via composer: https://github.com/sendpulse/sendpulse-rest-api-php
The situation is this:
In the directory with the theme, there is a functions.php file where there is a form handler, in which you can configure sending letters with requests from forms.
In this file, I added, according to the instructions from github sendpulse, the code for sending an email to the address book:
require '../private/vendor/autoload.php';
use Sendpulse\RestApi\ApiClient;
use Sendpulse\RestApi\Storage\FileStorage;
define('API_USER_ID', 'b7****************************************');
define('API_SECRET', 'e1*************************************');
$SPApiClient = new ApiClient(API_USER_ID, API_SECRET, new FileStorage());
$bookID = '15********';
$emailForSP = ['test6#test.ru'];
$SPApiClient->addEmails($bookID, $emailForSP);
If you just add this piece to the beginning of the file, then it works out and the address is added to the book. But sending letters to mail does not work, an error is thrown: https://hsto.org/webt/v8/qn/le/v8qnled6ibyy-ltp9afwyrjv-2q.jpeg
In the error_log file the line is: https://hsto.org/webt/mk/vo/g0/mkvog03mb7olfji0qrjcsyxktf0.jpeg
Error text from main.js file: https://hsto.org/webt/cd/-n/ry/cd-nryfx06_mvgtglu-t9msp8ga.jpeg
That is, this piece of code somehow affects the processing of the form handler function. In general, I need to trigger sending an email to the book after sending a letter to the mail, but in this case nothing works at all.
I didn't look for the cause of the conflict for a long time. Allocated sending e-mail in the sendpulse into a separate file and added ajax post request to this file. I don’t know why I hadn’t thought of this before.
let emailForSendPulse = $form.find('[name="email"]').val();
$.post('/wp-admin/smth.php', {email: emailForSendPulse}, function(data){
console.log('Form sended');
});
I am getting 555 syntax error in mailfrom
SendData(tcpSocket, string.Format("MAIL From: {0}\r\n", MailFrom));
if (!CheckResponse(tcpSocket, 220))
{
tcpSocket.Close();
return false;
}
is it the problem in my local system because of localhost?
Please help me. I am using this code from below link.
http://www.codeproject.com/Articles/5189/End-to-end-Email-Address-Verification-for-Applicat
Please don't try to implement your own SMTP client, use the one that comes with .NET: System.Net.Mail.SmtpClient.
Many SMTP servers require TLS, for example, which your code does not account for.
Furthermore, for security reasons most mailservers will not reveal if an email address in an RCPT TO line is valid or not. If a system can positively reveal an address exists then it can be used by spam harvesters. Consequently using a dry-run of an SMTP client should only be used to validate an email address (because of the complicated rules regarding valid email addresses). The verification (a separate concept from validation) must be performed manually by requiring the user to respond to an email sent to that address, there is no other way to be sure.
On the following page http://documentation.magnolia-cms.com/modules/mail.html#ConfiguringSMTP
In the section "Sending messages >> Plain text and HTML messages", we can read:
From:[...]Regardless of the address entered here, Magnolia CMS will use the smtpUser to send the email but the address here is displayed as the sender to the recipient. This means you can send an email from fake#address.com and it will appear to come from this address
However, when I receive the email I can still see the smtpUser config's email and my "fake#address.com" email address is not displayed (it is ignored!?)
Am I missing something? Thanks
I just tried this on the demo site at http://demoauthor.magnolia-cms.com/demo-project/service/contact.html and it seemed to work as expected.
Are you using a fresh install of Magnolia 4.4.5? Could you verify that you're hitting the "Edit Form Settings" button on the page, going to the "E-Mail" tab, and entering "fake#address.com" into the From field there? If you're then trying the form on a public instance, you'll need to be sure that the form page has been activated so that the public version of it has your "From" setting as well.