Sql script to find invalid email addresses

SELECT * FROM people WHERE email NOT LIKE ‘%_@__%.__%’ Anything more complex will likely return false negatives and run slower. Validating e-mail addresses in code is virtually impossible. EDIT: Related questions I’ve answered a similar question some time ago: TSQL Email Validation (without regex) T-SQL: checking for email format Regexp recognition of email address hard? … Read more

How can I get the error message for the mail() function?

If you are on Windows using SMTP, you can use error_get_last() when mail() returns false. Keep in mind this does not work with PHP’s native mail() function. $success = mail(‘example@example.com’, ‘My Subject’, $message); if (!$success) { $errorMessage = error_get_last()[‘message’]; } With print_r(error_get_last()), you get something like this: [type] => 2 [message] => mail(): Failed to … Read more

Converting HTML to plain text in PHP for e-mail

Use html2text (example HTML to text), licensed under the Eclipse Public License. It uses PHP’s DOM methods to load from HTML, and then iterates over the resulting DOM to extract plain text. Usage: // when installed using the Composer package $text = Html2Text\Html2Text::convert($html); // usage when installed using html2text.php require(‘html2text.php’); $text = convert_html_to_text($html); Although incomplete, … Read more

MailMessage, difference between Sender and From properties

Excerpt from the wiki on email: Header fields: The message header should include at least the following fields: From: The e-mail address, and optionally the name of the author(s). In many e-mail clients not changeable except through changing account settings. Also note that the “From:” field does not have to be the real sender of … Read more

How to to send mail using gmail in Laravel?

first login to your gmail account and under My account > Sign In And Security > Sign In to google, enable two step verification, then you can generate app password, and you can use that app password in .env file. Your .env file will then look something like this MAIL_DRIVER=smtp MAIL_HOST=smtp.gmail.com MAIL_PORT=587 MAIL_USERNAME=myemail@gmail.com MAIL_PASSWORD=apppassword MAIL_ENCRYPTION=tls … Read more

Read MS Exchange email in C#

It’s a mess. MAPI or CDO via a .NET interop DLL is officially unsupported by Microsoft–it will appear to work fine, but there are problems with memory leaks due to their differing memory models. You could use CDOEX, but that only works on the Exchange server itself, not remotely; useless. You could interop with Outlook, … Read more

Giving email account a name when sending emails with Django through Google Apps

You can actually use “Don’t Reply <do_not_reply@domain.example>” as the email address you send from. Try this in the shell of your Django project to test if it also works with gapps: >>> from django.core.mail import send_mail >>> send_mail(‘subject’, ‘message’, “Don’t Reply <do_not_reply@domain.example>”, [‘youremail@example.com’])

How to save MailMessage object to disk as *.eml or *.msg file

For simplicity, I’ll just quote an explanation from a Connect item: You can actually configure the SmtpClient to send emails to the file system instead of the network. You can do this programmatically using the following code: SmtpClient client = new SmtpClient(“mysmtphost”); client.DeliveryMethod = SmtpDeliveryMethod.SpecifiedPickupDirectory; client.PickupDirectoryLocation = @”C:\somedirectory”; client.Send(message); You can also set this up … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)