im getting this error when sending emails with cake's email component
[smtpError] => 535 5.7.1 http://mail.google.com/support/bin/answer.py?answer=14257 r11sm77490vbx.11
any ideas? here's my code...
$this->Email->to = array(' juan <name#gmail.com>');
$this->Email->from = 'name#gmail.com';
$this->Email->subject = 'Welcome to our really cool thing';
$this->Email->template = 'simple_message';
$this->Email->sendAs = 'both';
$this->Email->smtpOptions = array(
'port'=>'465',
'timeout'=>'30',
'auth' => true,
'host' => 'ssl://smtp.gmail.com',
'username'=>'name#gmail.com',
'password'=>'********',
);
You have a space there before your name, which could possibly be sending the wrong data. Have you tried the code without that extra space?
Well, the link in the error message to google's support forums say that the username and password combination are incorrect. I'd recommend that you try logging in to that gmail account with the specified password, just to triple check that you're not mistaken. That happens a lot to me, all the time.
Secondly, are you sure you're supposed to put the #gmail.com in for the username? Maybe it should just be 'name' rather than 'name#gmail.com'.
Apart from that stated by #Travis ... i would also suggest that the from should also be constructed in this format "Name " ... otherwise I don't think the email will go through.
Related
After subscription on my website form, I need to create the new contact on Mailjet and then add it to a specific list that already exist.
I have this following code which I execute after insert my user to database.
$firstname = "Michael";
$email = myemail#gmail.com;
$mj = new \Mailjet\Client($MJ_APIKEY_PUBLIC,$MJ_APIKEY_PRIVATE);
// create new contact on Mailjet
$contact_params = [
"Email" => $email
];
$response_add = $mj->post(Resources::$Contact, ['body' => $contact_params]);
// adding the created contact to my list
$list_params = [
'Name' => $firstname,
'Action' => "addnoforce",
'Email' => $email
];
$response_list = $mj->post(Resources::$ContactslistManagecontact, ['id' => 10181436, 'body' => $list_params]);
The contact is correctly created on Mailjet but never add to the list. The $response_list always give me back NULL and I don't really know why. I'm pretty new with Mailjet API, but I've following the official API and the way I want to do it seems correct. (https://dev.mailjet.com/email/reference/contacts/subscriptions#v3_post_contactslist_list_ID_managecontact)
Thanks for help :)
In case you are yet to find a solution.
Try this out, it works for me.
Check the "/contactslist/{list_ID or list_address}/managecontact" section on this documentation; https://dev.mailjet.com/email/reference/contacts/subscriptions#v3_post_listrecipient
Enjoy
I want to send emails to my users after they get registered in my site. Its like an account-activation mail. I have tried this, but its not working(its my own function from where I am trying to send mails) :
public function send_mail($from,$to,$subject,$msg,$value,$template){
$Email=new CakeEmail('smtp');
$Email->template('template','default')
->viewVars(array('value'=>$value))
->emailFormat('html')
->to($to)
->subject($subject)
->from(array($from=>'My Site'))
->send();
}
This is my email.php file's code :
<?php
class EmailConfig{
public $smtp=array(
'transport'=>'Smtp',
'from'=>array('notification#domain.com'=>'My Site'),
'host'=>HOST,
'port'=>PORT,
'timeout'=>30,
'username'=>'notification#domain.com',
'password'=>PASSWORD,
'client'=>null,
'log'=>false,
//'charset' => 'utf-8',
//'headerCharset' => 'utf-8',
);
}
Please help me. Is there anything wrong in my code, or, I have to do something else ?
Thanks.
I don't know if you replaced it with dummy data for security's sake, but all those fields in email.php need to contain valid information for an SMTP server. It won't ever work with blatantly false information like "notification#domain.com" as a username.
Not trying to be snarky; just not clear if you understood the default values need to be changed.
I'm trying to create a form that sends an email using SMTP authentication, but I keep receiving an error. I've read a bunch of posts online and this is the code I've come up with so far. Does anyone see anything wrong with the code below? Any help would be greatly appreciated.
Thanks
Bob
$configSMTP = array(
'port' => 587,
'auth' => 'login',
'username' => '***',
'password' => '***'
);
$transport = new Zend_Mail_Transport_Smtp('mail.server.com', $configSMTP);
$mail = new Zend_Mail();
$mail->setReplyTo($config['replyto']);
$mail->setBodyText($message);
$mail->setFrom($params[$config['emailID']], $params[$config['nameID']]);
$mail->addTo($config['sendto']);
$mail->setSubject($config['subject']);
try {
$mail->send($transport);
} catch(Exception $ex) {
Mage::getSingleton('core/session')->addError('There was an error submitting your request.');
}
Mandril's SMTP uses TLS.
http://help.mandrill.com/entries/21738477-What-SMTP-ports-can-I-use-
Enable it in your config array.
$configSMTP = array(
'ssl' => 'tls',
'port' => 587,
'auth' => 'login',
'username' => '***',
'password' => '***'
);
Would direct you maybe to section on resource plugins form Zend Mail. Give a better list of the options and shows how to assign them through your app.ini file.
That said, assuming your arguments are valid that looks fine.
What exception are you catching? You must be getting an error message. Can you telnet from this machine to your mail server? Want to eliminate network/auth issues.
It's hard to say without knowing what exception you're getting.
There might be several reasons, can you connect to the SMTP-server.. Is the port 587 really open? Do you have a firewall, and if so, might it be blocking the connection to that port? Are you really sure those credentials are valid? Have you tried manually connecting to the SMTP-server?
If not, see how you can do it with Telnet: How to test an SMTP server using Telnet
You could also try using a transactional email service. That way you wouldn't need to manage an SMTP-server or even think about deliverability, etc. You would just outsource it to someone else.
There are various providers, some of them are:
AlphaMail
Mandrill
PostageApp
If you're using AlphaMail, you could just use the AlphaMail PHP-client and send your emails like the example below:
include_once("comfirm.alphamail.client/emailservice.class.php");
$email_service = AlphaMailEmailService::create()
->setServiceUrl("http://api.amail.io/v1")
->setApiToken("YOUR-ACCOUNT-API-TOKEN-HERE");
$person = new stdClass();
$person->userId = "1234";
$person->firstName = "John";
$person->lastName = "Doe";
$person->dateOfBirth = 1975;
$response = $email_service->queue(EmailMessagePayload::create()
->setProjectId(12345) // You AlphaMail project (determines template, options, etc)
->setSender(new EmailContact("Sender Company Name", "from#example.com"))
->setReceiver(new EmailContact("Joe Doe", "to#example.org"))
->setBodyObject($person) // Any serializable object
);
The templates are constructed in the AlphaMail Dashboard using the Comlang templating language. This means that you can easily edit your emails at any time, without having to dig through code. Templates in Comlang look something like:
<html>
<body>
<b>Name:</b> <# payload.firstName " " payload.lastName #><br>
<b>Date of Birth:</b> <# payload.dateOfBirth #><br>
<# if (payload.userId != null) { #>
Sign Up Free!
<# } else { #>
Sign In
<# } #>
</body>
</html>
So I have a script that I'm trying to get VERP running correctly on. It's using MIME::Lite and postfix as the mail server. Here is the code:
use strict;
use MIME::Lite;
use LWP::Simple;
use Mail::Verp;
my $email = 'someuser#somesite.com';
Mail::Verp->separator('+');
my $verp_email = Mail::Verp->encode('root#somesite.net', $email);
my $content = '<html><body>Hi!</body></html>';
my $msg = MIME::Lite->new(
Subject => 'Hi',
From => 'root#somesite.net',
To => $email,
'Return-Path' => $verp_email,
Type => 'text/html',
Data => $content
);
$msg->send('smtp', 'XXX.XXX.XXX.XXX');
When the message is bounced postfix isn't routing it to the root#somesite.net email inbox. How do I route the message so that the sender of the bounce is the $verp_email value?
I'm trying to create a log of all bounced emails with the email addresses included so that it can then be sent to a file or a database.
If anyone can point me in the right direction with this I would be extremely appreciative.
Thanks.
Return-Path is not the correct place for the VERP address, and will be ignored and/or overridden. You need to put it as the actual, honest to $dmr, real SMTP envelope sender (MAIL FROM:<>) address.
The question is a bit old, but hopefully my answer will contribute to someone who find this while googling.
I had the same problem, and the root cause is that you must use "MAIL FROM: " during the smtp exchange with the target server.
Setting the return-path in the MIME::Header gets overwriten by the smtp server itself precisely based on the MAIL FROM smtp command.
So you can have a Mail envelope containing From: root#somesite.net but make sure the smtp MAIL FROM uses $verp_email
For example, this is what I have done:
my $msg = MIME::Entity->build(
'Return-Path' => 'bounce+user=user-domain.com#my-server.com',
'From' => 'admin#my-server.com',
'To' => 'user#user-domain.com',
'Subject' => $subject,
'Errors-To' => 'bounce+user=user-domain.com#my-server.com'
);
## Then some more handling with MIME::Entity
## and finally send it over smtp
my #rcpt = $msg->smtpsend(
## Make it verbose for debugging
'Debug' => DEBUG,
'Hello' => 'mx1.my-server.com',
'Host' => 'mx.user-domain.com,
'MailFrom' => 'bounce+user=user-domain.com#my-server.com',
'To' => 'user#user-domain.com',
'Port' => 25,
);
I'm building a CakePHP website that sends an e-mail like this:
$email = new CakeEmail('default');
$email->template('test');
$email->emailFormat('html');
$email->to(array('john_doe#example.com' => 'John Doe'));
$email->subject('Test E-mail');
$email->helpers(array('Html', 'Text'));
$email->viewVars(
array(
...
)
);
if ($email->send()) {
$this->Session->setFlash('The e-mail was sent!', 'default', array('class' => 'alert alert-success'));
}
else {
$this->Session->setFlash('An unexpected error occurred while sending the e-mail.', 'default', array('class' => 'alert alert-error'));
}
I'd like to be able to capture the HTML rendered by the e-mail in a variable in addition to actually sending the e-mail. This way, I can record in the database the exact content of the e-mail's body. Is this doable?
Per line 50 of the MailTransport class, it appears the actual send() function returns the message and the header. So instead of:
if($email->send()) {
Try:
$mySend = $email->send();
if($mySend) {
//...
Then, $mySend should be an array:
array('headers' => $headers, 'message' => $message);
Thats what I do in my EmailLib:
https://github.com/dereuromark/tools/blob/2.0/Lib/EmailLib.php
it logs email attempts and captures the email output into a log file (email_trace.log) in /tmp/logs/ - if you are in debug mode it will only log (no emails sent - this has been proven quite useful for local delopment).
you can write a similar wrapper for your case.
but if you want to write it back into the DB Dave's approach seems to fit better.