I am using CI library to send an email using Sendgrid smtp.
but it is not giving any response, neither email is sending.
$this->load->library('email');
$config['protocol'] = 'smtp';
$config['smtp_host'] = 'smtp.sendgrid.net';
$config['smtp_user'] = 'api key name';
$config['smtp_pass'] = 'api key';
$config['smtp_port'] = '587';
$config['smtp_keepalive'] = 'TRUE';
$this->email->initialize($config);
$this->email->from('test#test.com', FROM_NAME);
$this->email->to($email);
extract($arr_var);
$sub=addslashes($row['subject']);
eval("\$subject= \"$sub\";");
$body=addslashes($row['message']);
eval("\$message= \"$body\";");
if ($subject!='') {
$this->email->subject(stripslashes($subject));
} else {
$this->email->subject($row['subject'].' - '.$this->config->item('app_title'));
}
$this->email->message($message);
$bool=$this->email->send();
Using above code i am sending en email CI v3 but it I am not receiving any email?
Twilio SendGrid developer evangelist here.
Two things stand out to me here.
First, where you set the smtp username, it should be the string "apikey" (see the instructions for sending with SMTP here).
Second, the from address you are sending from is "test#test.com". SendGrid requires you to verify the identity you send from. You either need go through Single Sender Verification or Domain Authentication and then use an email address that you have verified to send the emails from.
Once you have sorted those two bits out, your emails should send successfully.
Related
I am using MailKit to reply to an email received from a Gmail account. I set the value of the In-Reply-To and References header as described in the MailKit documentation:
if (!string.IsNullOrEmpty(replyMessage.MessageId)) {
message.InReplyTo = replyMessage.MessageId;
foreach (var id in replyMessage.References) {
message.References.Add(id);
}
message.References.Add(replyMessage.MessageId);
}
Given this, I expect the reply mail to show up in Gmail as a reply to the original message. However, this does not happen. The mail is shown like any other random new mail.
Am I missing something?
You also need to set to message.Subject to “Re: “ + replyMessage.Subject
I need to send an email via MATLAB and I've read the instructions for sendmail and lots of answers around here. I've tried 3 email providers and I can't really use any of them:
Gmail: I can only send email when I deactivate my anivirus
Hotmail and Yahoo: Error using sendmail (line 171) Exception reading response; Connection reset
Hotmail and Yahoo (antivirus off): Error using sendmail (line 171) Exception reading response; Unrecognized SSL message, plaintext connection?
Here's the code
mail = 'user#service.com';
password = 'passwordgoeshere';
setpref('Internet','SMTP_Server','smtp.server.com');
setpref('Internet','E_mail',mail);
setpref('Internet','SMTP_Username',mail);
setpref('Internet','SMTP_Password',password);
props = java.lang.System.getProperties;
props.setProperty('mail.smtp.auth','true');
props.setProperty('mail.smtp.socketFactory.class', 'javax.net.ssl.SSLSocketFactory');
props.setProperty('mail.smtp.socketFactory.port',port);
sendmail(mail,'Test from MATLAB','Hello! This is a test from MATLAB!')
I've used the following variables:
Gmail: smtp.gmail.com port=465
Hotmail: smtp.live.com port=465 and port=587
Yahoo: smtp.mail.yahoo.com port=587
Since deactivating the antivirus is not a good option, can anyone help me solving this?
Thank you
An alternative way on linux is to run a command line that send the email.
unix('echo "message" | mail -s "subject" example#gmail.com');
A similar method should be available for windows.
For Gmail
Change your settings to allow less secure apps to access your account. Go to the "Less secure apps" section in My Account.
Next to "Access for less secure apps," select Turn on. (Note to Google Apps users: This setting is hidden if your administrator has locked less secure app account access.)
In Matlab:
mail = 'user#otherdomain.com';
password = 'myPassword';
% Set up the preferences
setpref('Internet','E_mail',mail);
setpref('Internet','SMTP_Server','smtp.gmail.com');
setpref('Internet','SMTP_Username',mail);
setpref('Internet','SMTP_Password',password);
% The following is necessary only if you are using GMail as
% your SMTP server.
props = java.lang.System.getProperties;
props.setProperty('mail.smtp.auth','true');
props.setProperty('mail.smtp.socketFactory.class', 'javax.net.ssl.SSLSocketFactory');
props.setProperty('mail.smtp.socketFactory.port','465');
subject = 'Test subject';
message = 'Test message';
sendmail(mail,subject,message)
Simply declare
mail = 'user';
Drop the extension #service.com for the variable mail.
I already deployed the Email Service I developed on the Chicago Server. Last Friday 11:30pm in Philippine time, I tested the sending and it run's properly, but when I checked my email there's no message in inbox or spam. And then, Saturday 1:30am, I've noticed that I received the message that I tested last Friday.
Please advice me guys! thanks!
My Questions is:
a.) Do I need to configure something on the Server to make the real time receiving on emails?
here's my code:
//send email
MailMessage objEmail = new MailMessage(new MailAddress(ConfigurationManager.AppSettings["emailAdd"].ToString()), new MailAddress(ConfigurationManager.AppSettings["emailAdd"].ToString()));
objEmail.Subject = "Test";
objEmail.Body = "CODE:" + _Message;
objEmail.Priority = MailPriority.High;
SmtpClient SmtpMail = new SmtpClient();
SmtpMail.Host = "localhost";
SmtpMail.Send(objEmail);
Put this one on your code:
SmtpMail.DeliveryMethod = SmtpDeliveryMethod.PickupDirectoryFromIis;
And also, configure the relay restrictions on the SMTP server that will allow your 120.0.0.1/localhost..
Last, configure the firewall and port forwarding on the server.
I hope this will help you..
I have a client with 5000 emails from an old list he has that he wants to promote his services to. He wants to know which emails on the list are still valid. I want to check them for him - without sending out 5K emails randomly and then being listed as a spammer or something. Ideas?
You can validate the email via SMTP without sending an actual email.
http://code.google.com/p/php-smtp-email-validation/
You could also send emails out, and check for bounces.
bucabay's answer is the way forward. What a library like that essentially does is checking for existing DNS record for (mail) servers at specified domains (A, MX, or AAAA). After that, it do what's termed callback verification. That's where you connect to the mail server, tell it you want to send to a particular email address and see if they say OK.
For callback verification, you should note greylisting servers say OK to everything so there is no 100% guarantee possible without actually sending the emails out. Here's some code I used when I did this manually. It's a patch onto the email address parser from here.
#
# Email callback verification
# Based on http://uk2.php.net/manual/en/function.getmxrr.php
#
if (strlen($bits['domain-literal'])){
$records = array($bits['domain-literal']);
}elseif (!getmxrr($bits['domain'], $mx_records, $mx_weight)){
$records = array($bits['domain']);
}else{
$mxs = array();
for ($i = 0; $i < count($mx_records); $i++){
$mxs[$mx_records[$i]] = $mx_weight[$i];
}
asort($mxs);
$records = array_keys($mxs);
}
$user_okay = false;
for ($j = 0; $j < count($records) && !$user_okay; $j++){
$fp = #fsockopen($records[$j], 25, $errno, $errstr, 2);
if($fp){
$ms_resp = "";
$ms_resp .= send_command($fp, "HELO ******.com");
$ms_resp .= send_command($fp, "MAIL FROM:<>");
$rcpt_text = send_command($fp, "RCPT TO:<" . $email . ">");
$ms_resp .= $rcpt_text;
$ms_code = intval(substr($rcpt_text, 0, 3));
if ($ms_code == 250 || $ms_code == 451){ // Accept all user account on greylisting server
$user_okay = true;
}
$ms_resp .= send_command($fp, "QUIT");
fclose($fp);
}
}
return $user_okay ? 1 : 0;
I think you need to send the emails to find out. Also, this is pretty much exactly what a spammer is, thus the reason for getting put on spammer lists. Sending in bursts will help you hide this fact though.
You'll have to email them at least once.
Create a new email list. Send the old list an email with a link they need to click on to continue receiving messages (re-subscribe).
Send them all an email and collect all reply-to bounces on a real email account, then purge those bounced emails from your main list.
Send them all an HTML email, and one of the images is remotely hosted and requires a unique ID to request it that you set in each email. When your web server returns that image to their client, you can then consider that email as active. This is called a web bug, and will only work if the person automatically loads remote images in their client.
https://github.com/kamilc/email_verifier is a rubygem that will check that the MX record exists and that the SMTP server says the address has a valid mailbox.
You can use a paid service like Kickbox to do this as well.
You can consider the MailboxValidator service http://www.mailboxvalidator.com/ which should be adequate for your requirement. You can get either a bulk plan where you can upload a CSV file containing your email list or get the API plan if you require programmatic integrations.
I try to send a simple Email via CakePHP's Email Component. I'm using following code from the cookbook documentation:
$this->Email->from = 'Irgendjemand <irgendjemand#example.com>';
$this->Email->to = 'Irgendjemand Anderes <irgendjemand.anderes#example.com>';
$this->Email->subject = 'Test';
$this->Email->send('Dies ist der Nachrichtenrumpf!');
The send()-method does only return a boolean value with the value false - but no error or warning occurs.
Does somebody have a solution for that?
Have you tried changing the delivery options? There are three options: mail, smtp and debug.
$this->Email->delivery = 'debug';
$this->Email->send('test message');
debug($this->Session->read('Message.email'));
You can debug with EMail. Set the delivery to debug and the email message will be set to Session.message:
if (Configure::read('debug') > 1) {
$this->Email->delivery = 'debug';
}
$ret = $this->Email->send();
if (Configure::read('debug') > 1) {
pr($this->Session->read('Message.email'));
}
Which OS are you on? If Windows, this note may be of interest:
Note: The Windows implementation of mail() differs in many ways from the Unix implementation.
...
As such, the to parameter should not be an address in the form of
"Something <someone#example.com>". The mail command may not parse this properly while talking with the MTA.
Secondly, it may just be the case that no mail server will accept outgoing mail from your local machine due to spam protection. I have often seen that the same mail() function will not work locally, but works fine once uploaded to a trustworthy server. You could try to use an authenticated mail relay in that case (SMTP).